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

Steve Bennett stevagewp at gmail.com
Sun Feb 3 06:38:37 PST 2008


Dammit, I found the error. I didn't realise (or forgot) that gated
predicates apply at the subrule level, not just the rule level.

ESCAPED_PUNC     : {this.in_noparse}? => ('#' | '*' | ':' | ';' | '|'
| '[' | ']' | '=' | '/');

is correct.

ESCAPED_PUNC     : {this.in_noparse}? => '#' | '*' | ':' | ';' | '|' |
'[' | ']' | '=' | '/';

is incorrect.

Ouch. What a lot of time spent on what turned out to be missing parentheses.

I have also learnt that this kind of construct is incorrect:

FOO: {flag}? => 'X';
UNFOO: 'X';

You need to specify the reverse semantic predicate.

Anyway, thanks for listening everyone, you've been very supportive :)

Steve


More information about the antlr-interest mailing list