[antlr-interest] optional rule confusion

Igor Fedorenko ifedorenko at rogers.com
Wed Mar 3 05:28:23 PST 2004


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

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