[antlr-interest] Re: optional rule confusion

mzukowski at yci.com mzukowski at yci.com
Wed Mar 3 09:21:10 PST 2004


Yeah, it's only real purpose is for lexers.  In parsers it might just pass
through and make that method protected, I'm not sure.  In any event it
doesn't alter antlr's behavior.

Monty

-----Original Message-----
From: Lubos Vnuk [mailto:lubos.vnuk at rts.at] 
Sent: Wednesday, March 03, 2004 7:08 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Re: optional rule confusion

I always thought the keyword protected was meant for lexers only.

--- In antlr-interest at yahoogroups.com, Igor Fedorenko 
<ifedorenko at r...> wrote:
> Thank you for the hint, Lubos, Adding dummy rule does the trick. 
Note 
> however, that my rule is protected so there is no way it can be 
called 
> as a top level rule.
> 
> Lubos Vnuk wrote:
> 
> > I think you can get some information from a similar thread 
> > titled: "Problem with x: (A)(B)? ; "
> > 
> > Regards,
> > Lubos.
> > 
> > --- In antlr-interest at yahoogroups.com, Igor Fedorenko 
> > <ifedorenko at r...> wrote:
> > 
> >>I must be missing something really simple, but I cannot get antlr 
> >>generate reasonable parser for javadoc-like java method names 
(like 
> >>com.something.MyClass#method).
> >>
> >>Here is what my parser rule looks like
> >>
> >>     protected javaname: ID (DOT ID)* (POUND ID)?
> >>
> >>And here is what antlr generates for the last part
> >>
> >>     switch ( LA(1)) {
> >>     case POUND:
> >>       {
> >>       match(POUND);
> >>       m = LT(1);
> >>       match(ID);
> >>       break;
> >>       }
> >>     case EOF:
> >>       {
> >>       break;
> >>       }
> >>     default:
> >>       {
> >>       throw new NoViableAltException(LT(1), getFilename());
> >>       }
> >>     }
> >>
> >>
> >>Why would antlr generate NoViableAltException for something which 
> > 
> > is 
> > 
> >>optional?
> >>
> >>
> >>Regards,
> >>Igor Fedorenko
> > 
> > 
> > 
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> >



 
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