[antlr-interest] Re: Backtrack option breaks AST rewrite

Terence Parr parrt at cs.usfca.edu
Mon Jul 24 11:35:53 PDT 2006


On Jul 23, 2006, at 2:20 AM, Thomas Brandon wrote:

> 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.

This should not be anything related to memoization, it is however a  
problem with the manner in which I auto generate predicates. :)

I'll have a fix for you shortly.

Ter



More information about the antlr-interest mailing list