[antlr-interest] Re: changing a token type at the parser level

Chris Black cblack0 at yahoo.com
Fri May 14 15:53:26 PDT 2004


--- In antlr-interest at yahoogroups.com, Mark Lentczner <markl at g...> wrote:
> > Unfortunately, whenever I have an empty rule like:
> >
> > empty: ;
> >
> > in my parser, the generated java does not compile since it comlains
> > about an unreachable catch block since an empty rule will not throw a
> > RecognitionException:
> 
> > Any ideas?
> How'z'bout:
> 
> empty options{defaultErrorHandler=false;}: ;
> 
> See:
> 	http://www.antlr.org/doc/options.html#defaultErrorHandler
> 
> Sorry I didn't catch that...
> 
> 	- Mark
> 

Oddly enough I was looking at that option a few weeks ago...

What I ended up doing was:

optionalField: f:FIELD { ## = #[ABSENT,"absent empty tok"]; }
| { ## = #[ABSENT,"absent empty tok"]; }

Which works fine.

Thanks for your help!
Chris



 
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