[antlr-interest] need help with predicates

Richard Clark rdclark at gmail.com
Thu Aug 9 09:06:38 PDT 2007


The usual answer to dealing with context-dependant elements is to move
the decision from the lexer into the parser.

You might do this:

identifier: (ID_FRAGMENT '!' ID_FRAGMENT) => ID_FRAGMENT '!' ID_FRAGMENT
             | ID_FRAGMENT
             /* You still have to deal with the other suffixes */
             ;

ID_FRAGMENT: LETTER (LETTER| DECIMAL_LITERAL)* ;

 ...Richard


More information about the antlr-interest mailing list