[antlr-interest] semantic predicates use LT() on IntStream - bad
Terence Parr
parrt at cs.usfca.edu
Thu Nov 1 11:45:38 PDT 2007
On Nov 1, 2007, at 11:18 AM, Mats Behre wrote:
> Hello
>
> I have solved my earlier problem (http://www.antlr.org/
> pipermail/antlr-interest/2007-October/024485.html) at least
> temporarily by post-processing the generated Java file, but now I
> have stumbled upon a new one.
> The language I'm converting the grammar for, in addition to having
> loads of keywords, also allows the keywords to be used as
> identifiers such as variable names, so I have added rules such as
> this one from the 'The Definitive ANTLR Reference' book:
>
> keyIF : {input.LT(1).getText().equals("if")}? ID ;
>
> Now I get Java compiler errors, because in DFA classes there are
> methods named 'specialStateTransition', where input is an
> IntStream, which obviously use these semantic predicates, and
> IntStream does not have an LT(int) method.
> This time I haven't slightest idea of how to work around the
> problem, but I'll try to wade through the LL(*) section of the
> book, hoping to find a solution.
doh! Sorry. Can you try casting input to CommonTokenStream or
whatever you're using?
Ter
More information about the antlr-interest
mailing list