[antlr-interest] The power of backtracking in ANTLR

Gavin Lambert antlr at mirality.co.nz
Sun Feb 14 23:52:02 PST 2010


At 14:54 15/02/2010, Michael Bedward wrote:
 >So, in this example you can't refactor the grammar to LL(k) but
 >you can have a simple, readable grammar for this part of the
 >language if you work with a back-tracking parser.

Or you put in the appropriate look-ahead predicates yourself.

Basically all ANTLR's backtracking mode does is to insert 
lookahead predicates in every path and switch off ambiguity 
warnings.  Consequently, while it's often useful while 
experimenting, or with ridiculously ambiguous languages, it's 
usually better to keep backtracking off, refactor, and add 
predicates as needed.



More information about the antlr-interest mailing list