[antlr-interest] How can I work around approximate LALL limitation?
Case, Scott
scott.case at ca.com
Mon Nov 11 06:40:42 PST 2002
Maybe try this -
table:
(INTEGER
( (SPACE INTEGER)=> SPACE INTEGER
| (SPACE NEWLINE)=> SPACE
)*
NEWLINE)+
;
/*
INTEGER NEWLINE
INTEGER SPACE NEWLINE
INTEGER SPACE INTEGER NEWLINE
INTEGER SPACE INTEGER SPACE NEWLINE
*/
- Scott
-----Original Message-----
From: Pete Forman [mailto:pete.forman at westerngeco.com]
Sent: Monday, November 11, 2002 7:07 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] How can I work around approximate LALL
limitation?
[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/
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list