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

Bharath bharath at starthis.com
Tue May 18 10:52:43 PDT 2004


Hi John,

You are right. I changed the rule when my test cases failed but I forgot to
include the change in my reply to you. The reason is, my actual rule is much
more complicated and I replaced the complex part with IDENT, just for
simplicity and to easily understand the problem. Thank you very much though,
for notifying the error!

Thanks again to you and Mark.

Bharath.



-----Original Message-----
From: John B. Brodie [mailto:jbb at cfl.rr.com] On Behalf Of jbb at acm.org
Sent: Tuesday, May 18, 2004 11:35 AM
To: antlr-interest at yahoogroups.com
Subject: Re: [antlr-interest] greedy/non-greedy problem.

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



 





 
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