[antlr-interest] greedy/non-greedy problem.

Mark Lentczner markl at glyphic.com
Tue May 18 08:15:25 PDT 2004


On May 18, 2004, at 7:35 AM, Bharath wrote:

> myParserRule: IDENT DOT IDENT DOT (IDENT DOT)* IDENT;

The problem is that while normally a DOT must be followed by IDENT, the 
second DOT doesn't have this issue (odd grammar, if you ask me, but 
what do I know about what you're parsing...)

Try this:

myParserRule: IDENT DOT IDENT DOT (IDENT (DOT IDENT)*)? ;

Without knowing the rest of the grammar I can't say if this will solve 
the issue.  But, generally speaking, moving optional sections to the 
end of a rule is better than having them in the middle.

	- Mark

Mark Lentczner
markl at wheatfarm.org
http://www.wheatfarm.org/



 
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