[antlr-interest] Double Left Recursion Update: Test case with working "double left recursion"
Jan Finis
finis at in.tum.de
Tue Feb 28 06:11:48 PST 2012
Hi again,
as I mentioned in my last mail, I think that the problem with rules of
the form
expr : expr expr;
is solvable because old Honey Badger was able to match them. I tried
again and could confirm this. This grammar:
result : expr { System.out.println($expr.s); } EOF;
expr returns [String s]
: 'x' { $s = "x"; }
| e1=expr '?' { $s = $e1.s + "?"; }
| e1=expr e2=expr { $s = "(" + $e1.s + " " + $e2.s + ")"; }
;
parses correctly with an older 4.0ea version. I have uploaded this
version here:
http://www-db.in.tum.de/~finis/antlr-4.0ea-complete-old.jar/
It does not only parse correctly, even the resulting parser is really
able to match input without descending into a looping recursion.
I tested the resulting parser on the following input:
xxxxx?xx?xx
and the result was:
(x (x (x (x (x? (x (x? (x x))))))))
so the concatenation operation seems to be right associative, but it
works perfectly fine :).
Best regards,
Jan
More information about the antlr-interest
mailing list