[antlr-interest] Semantic predicates in v4 lexer rules

A Z asicaddress at gmail.com
Mon Jan 23 10:31:57 PST 2012


Can we still use sementic predicates in lexer rules using v4? The following
code works in 3.4 but 4.0ea complains with

error(15): TestLexer.g:484:29: '{keywords == true}?' came as a complete
surprise to me while looking for lexer rule element


K_IF                       : {keywords == true}? => 'if';
K_INT                      : {keywords == true}? => 'int';


The language I'm using allows changing the keyword set via preprocessor
directives so all the keywords need to test a variable at runtime. Is there
another way to do this in v4?


More information about the antlr-interest mailing list