Open ivan-gavran opened 7 years ago
mmm... in Python3 Interval is a range (with start and stop fields), so while your proposal might work, it would hide the underlying issue.
Could it then be that I was passing the wrong type of argument to function getText()? So, what I did was (in short) (in a listener callback, with rewriter being an instance of TokenStreamRewriter)
intervalVar = ctx.getSourceInterval()
//some rewriting
rewriter.getText("default", intervalVar)
However, if not intervalVar
, then what should've been given as an argument to getText
function?
Hi,
looks like getSourceInterval returns a tuple, which I believe to be a bug (need further digging to be sure). Please keep this issue open so I can fix it when I have time. In the meantime, I’d suggest you convert the result to a range when passing it to getText
Eric
Le 22 sept. 2017 à 01:02, gergia notifications@github.com a écrit :
Could it then be that I was passing the wrong type of argument to function getText()? So, what I did was (in short) (in a listener callback, with rewriter being an instance of TokenStreamRewriter)
intervalVar = ctx.getSourceInterval() //some rewriting rewriter.getText("default", intervalVar) However, if not intervalVar, then what should've been given as an argument to getText function?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/antlr/antlr4/issues/2020#issuecomment-331218794, or mute the thread https://github.com/notifications/unsubscribe-auth/ADLYJLjs2PgmnKeH83taptVX_K7LYAjwks5skpYvgaJpZM4Penmf.
In TokenStreamRewriter, the function getText() tries to access fields start and stop of provided interval argument
However, it seems that interval is an ordinary tuple. Therefore, what works is
I also checked in the rest of the codebase, and the suggested fix was done in e.g. BufferedTokenStream. Does this change make sense?