[antlr-interest] Confused about backtracking

franck102 franck102 at yahoo.com
Mon Nov 28 10:11:43 PST 2011


None of those suggestion will help with the actual grammar unfortunately. It
is indeed ambiguous, that is the warning I get if I turn backtracking off,
but I can't refactor the rules (or the actual, large grammar) w/o ending
with a completely meaningless AST.

I still don't understand why antlr won't backtrack there, I suspect this is
a limitation of the implementation strategy that uses predicates; or maybe I
am expecting too much and the kind of backtracking required here would be
too hard or expensive to implement?
Basically I have an ambiguous but valid non left-recursive grammar, and I
don't see why antlr after failing on one branch doesn't backtrack to try the
other branch of the ambiguity.

I do use the debugger, and it shows that the (automatically generated)
syntactic predicate for expr passed ( DOT ^( EXPR "c" ) ) and that b.c was
accepted as an expr, and the next node in the parse tree is the
MissingTokenExpression at = (the parser expects a separator at that point).

Replacing the '.' literal by an explicit DOT token doesn't make any
difference.

--
View this message in context: http://antlr.1301665.n2.nabble.com/Confused-about-backtracking-tp7033712p7039721.html
Sent from the ANTLR mailing list archive at Nabble.com.


More information about the antlr-interest mailing list