[antlr-interest] Confused about backtracking
franck102 at yahoo.com
Mon Nov 28 10:26:58 PST 2011
This is a 20 years old language with zillions of existing lines of code. If I
can get the parser to work even with an awful lot of backtracking then I can
use it to write a translator that cleans up those kind of stupid idioms...
I think your answer gave me the clue I needed though, apparently
backtracking works between alternatives but consuming or not consuming one
instance of a ( )* construct is not considered an alternative. If I replace
the * construct with tail recursion in my example things work fine - I need
to see if that is something I can do in the real grammar.
So my grammar works fine in this form (rest unchanged):
: statement* EOF
: ID '=' expr
expr : ID suffix;
suffix : DOT expr
| /* nothing */
View this message in context: http://antlr.1301665.n2.nabble.com/Confused-about-backtracking-tp7033712p7039813.html
Sent from the ANTLR mailing list archive at Nabble.com.
More information about the antlr-interest