[antlr-interest] ANTLR3.4: help on @init and @after
Francis ANDRE
francis.andre.kampbell at orange.fr
Tue Aug 21 00:32:50 PDT 2012
Hi
This parser rule
foo
returns[Token = null]
@init
{ allowFOO(true); }
@after
{ allowFOO(false); }
: FOO { l = $FOO; }
;
is translated into this snippet
allowFOO(true);
try {
{
FOO1=(Lexem)match(input,FOO,FOLLOW_FOO_in_FOO1247); if
(state.failed) return l;
if ( state.backtracking==0 ) { l = FOO1; }
}
if ( state.backtracking==0 ) { allowFOO(false); }
Why the @after action is conditioned by a backtracking equal to 0, while
the @init one is not??
FA
More information about the antlr-interest
mailing list