[antlr-interest] Re: Backtrack option breaks AST rewrite
Thomas Brandon
tbrandonau at gmail.com
Sun Jul 23 02:20:16 PDT 2006
I found another issue with backtracking. With backtrack and memoize on
the use of labels can result in invalid code. For example the
following grammar:
grammar BTErr2;
options {
backtrack=true;
memoize=true;
k=2;
output=AST;
}
a: 'c' dl=d
| 'c' d
;
d: 'd' ;
gives java error "dl cannot be resolved" in BTErr2.java. The
combination of backtracking and memoization results in ANTLR
generating a syntactic predicate "( 'c' dl= d )=>", which is
implemented in a synpred1_fragment method, with the label assignment
resulting in "dl=d();" but dl is not defined in the synpred method.
Tom.
More information about the antlr-interest
mailing list