[antlr-interest] Bug with predicates and DFAs? (ANTLR 3.0)
Braun, Kevin T
Kevin.Braun at fnis.com
Fri Aug 17 11:02:12 PDT 2007
Hi,
I tried using this rule:
keywordSet
: {setCanBeId &&
input.LT(1).getText().equals("set")}? IDENT;
in order to allow "set" to appear either as a keyword or as an
identifier. The rule where keywordSet is used ends up being involved in
an LL(*) decision. In the generated parser, the code in the DFA has a
method specialStateTransition declared as:
public int specialStateTransition(int s, IntStream input) throws
NoViableAltException
The predicate from keywordSet ends up in this specialStateTransition
method (I guess that's the predicate hoisting), but this results in
invalid code: inside this method, input is an IntStream and
IntStream.LT() returns an int, not a token object. That makes
input.LT(1).getText() invalid.
Regards,
Kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070817/aae6d685/attachment-0001.html
More information about the antlr-interest
mailing list