[antlr-interest] How can I work around approximate LALL limitation?
Pete Forman
pete.forman at westerngeco.com
Mon Nov 11 04:06:58 PST 2002
[apologies for previous partial message]
I've run into a problem which is exemplified thus.
class ExampleParser extends Parser;
options { k = 2;}
table: (INTEGER (SPACE INTEGER)* (SPACE)? NEWLINE)+;
ANTLR Parser Generator Version 2.7.1 1989-2000 jGuru.com
example.g:4: warning: nondeterminism upon
example.g:4: k==1:SPACE
example.g:4: k==2:INTEGER
example.g:4: between alt 1 and exit branch of block
(The problem is the same with 2.7.2a4 (20021027-1))
Now I think that I understand what the problem is. It is described
in http://www.jguru.com/faq/view.jsp?EID=264825. What is not obvious
is how to work around it. Discarding SPACE tokens is not an option in
the full grammar that I want to fix.
Both the following have no errors.
table: (INTEGER (SPACE INTEGER)* SPACE NEWLINE)+;
table: (INTEGER (SPACE INTEGER)* NEWLINE)+;
But this doesn't work.
table: (INTEGER (SPACE INTEGER)* (SPACE NEWLINE|NEWLINE))+;
--
Pete Forman -./\.- Disclaimer: This post is originated
WesternGeco -./\.- by myself and does not represent
pete.forman at westerngeco.com -./\.- opinion of Schlumberger, Baker
http://petef.port5.com -./\.- Hughes or their divisions.
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list