[antlr-interest] Re: Problem with x: (A)(B)? ;

Ric Klaren klaren at cs.utwente.nl
Thu Feb 26 02:09:15 PST 2004


Hi,

CC'ing Ter since I did not hear from a previous report on this behaviour ;)

On Wed, Feb 25, 2004 at 03:29:40PM -0000, dotlessbraille wrote:
> OK, let me try again.
> 
> I have a large grammar which works fine. Lexer rules of the form 
> A:'a'('b')? and A:'a'('b')* both generate the expected 
> implementation (in Java).  A parser rule of the form x:A(B)* also 
> works as expected.  
> 
> However, when I added a parser rule of the form x:A(B)?, ANTLR 
> generated a switch statement which requires an EOF in the case there 
> is not a B.
> 
> Is this a bug or a feature?

I'd call it a nasty quirk for now. Only workaround I've seen is adding a
dummy rule which says anything may follow x:

dummy: x ( . )* ;

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
 "Don't call me stupid." "Oh, right. To call you stupid would be an insult
    to stupid people. I've known sheep that could outwit you! I've worn
              dresses with higher IQs!" --- A Fish Called Wanda



 
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