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

jbb at acm.org jbb at acm.org
Tue May 18 09:34:40 PDT 2004


Bharath :-

>I replaced it with IDENT DOT IDENT DOT (IDENT (DOT IDENT)*)? And it worked.

Good. I am glad that worked for you.

But you do realize that the above rule recognizes a different
language than your original rule?

If remember correctly your original rule was:

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

in which the third, trailing, IDENT is a REQUIRED element, while in:

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

the third, trailing, IDENT is an OPTIONAL element.

Thus I think that the second rule accepts "a.b." while the first would
reject.



 
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