[antlr-interest] semantic predicates use LT() on IntStream - bad

Mats Behre mb.fgel at ownit.nu
Thu Nov 1 11:18:34 PDT 2007


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.

Rgds,
Mats


More information about the antlr-interest mailing list