[antlr-interest] What's the difference between:
Steve Bennett
stevagewp at gmail.com
Sun Nov 25 13:07:35 PST 2007
a) an @init block and a
This:
rule: { code;} foo;
and:
---
rule
@init {code;}
:foo;
---
Do they behave differently with syntactic predicates and/or
backtracking, perhaps? I'm thinking that actions only get run if the
rule matches, but perhaps the @init always gets run?
Similarly, what's the difference between:
rule: foo {code;};
and
---
rule
@after { code; }
:foo;
---
and
---
rule: foo;
finally {code; }
---
Lastly, given all that, what is the best way to set and unset a
context variable for the duration of matching a given rule? Is it as
follows:
---
rule
@init { this.in_rule=true; }
:foo;
finally { this.in_rule=false;}
---
Thanks all,
Steve
More information about the antlr-interest
mailing list