[antlr-interest] Re: optional rule confusion

Igor Fedorenko ifedorenko at rogers.com
Wed Mar 3 05:53:51 PST 2004


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

<*> 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