[antlr-interest] Gated semantic predicates behaving like validating predicates

Gavin Lambert antlr at mirality.co.nz
Sun Feb 3 11:24:54 PST 2008


At 01:21 4/02/2008, Steve Bennett wrote:
 >
 >ESCAPED_PUNC     : {in_noparse}? => '#' | '*' | ':' | ';' | '|' 
|
 >'[' | ']' | '=' | '/';
 >
 >
 >HASH            : {!in_noparse}? => '#';
 >ASTERISK        : {!in_noparse}? => '*';

Given that you're matching the same characters in both, I'd turn 
this around:

HASH  :  '#' { if (in_noparse) { $type = ESCAPED_PUNC; } };
...

Seems simpler.

Or even just leave it as a HASH and deal with the difference in 
the parser instead, but that depends on how your grammar is 
structured.



More information about the antlr-interest mailing list