[antlr-interest] Lexer rule match keyword or identifier depending on the previous token

Gavin Lambert antlr at mirality.co.nz
Mon Aug 20 03:46:12 PDT 2007


At 21:44 20/08/2007, Guillaume Chavanon wrote:
 >I am writing a grammar for a language that allow some keywords 
to
 >be identifiers if they are preceded by a special character.
 >Is it possible to add gated semantic predicate in a lexer rule 
that
 >will test the previous token ?

Possibly, but wouldn't it be easier to match the special character 
and then say "anything after this must be an identifier"?



More information about the antlr-interest mailing list