[antlr-interest] syntactic predicates vs. backtrack=true

Johannes Luber jaluber at gmx.de
Tue Feb 5 06:05:53 PST 2008


Mark Volkmann schrieb:
> Thanks! I learned some new things by reading that. I'm still a little
> confused though. In section 12.2 of the book (page 300 in my copy) it
> says:
> 
> "ANTLR also supports an auto-backtracking feature whereby ANTLR
> inserts syntactic predicates on the left edge of every alternative."
> 
> So it seems to me that these rules are equivalent in both behavior and
> performance.
> 
> foo
> options { backtrack = true; }
>   : option1
>   | option2
>   | option3
>   ;
> 
> foo
>   : (option1)=> option1
>   | (option2)=> option2
>   | option3
>   ;
> 
> If this is true then I think I prefer using backtrack because it adds
> less clutter to the rule.
> 

I'm not sure if that is the only tradeoff here, but Ter can answer this 
better than I can here.

Johannes


More information about the antlr-interest mailing list