[antlr-interest] ANTLR not generating correct end condition on greedy=false loop.
Daniel Shane
lachinois at hotmail.com
Fri Jan 16 12:24:52 PST 2004
Hi,
Why does this grammar result in an invalid condition to break out of the
loop:
a: LCURLY any RCURLY;
b: PLUS any MINUS;
any: ( options { greedy=false; } : . )*;
On input
{ fdsfa + fdsfds - fdsfds }
The condition for end of loop is all tokens that can follow any (in this
case MINUS and RCURLY) even if its quite obvious from the grammar that when
inside rule a, rule b can never trigger. This of course will give an invalid
parse because the loop will stop at - and it will expect a RCURLY.
To make this grammar work I have to write:
a: LCURLY ( options { greedy=false; } : . )* RCURLY;
b: PLUS ( options { greedy=false; } : . )* MINUS;
so that the end condition is ok. Is there a way to make the above grammar
work? Is there a good reason for this kind of limitation?
Daniel Shane
_________________________________________________________________
MSN Search, le moteur de recherche qui pense comme vous !
http://fr.ca.search.msn.com/
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list