[antlr-interest] Re: "protected" lexer rules

micheal_jor open.zone at virgin.net
Mon Nov 8 14:24:07 PST 2004



--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at c...> wrote:
> 
> On Nov 8, 2004, at 12:51 PM, Tim Simpson wrote:
> > Currently I'm toying around with antlr, trying to learn the
> > in's and out's. It is a very useful tool. I was thinking about
> > this sub/protected rules, and it kind of reminds me of some
> > stuff from functional programming.
> >
> > So what about
> >
> > INT : (DIGIT)+
> > where {DIGIT : '0'..'9';};
> >
> > Of course this would only make the definition of DIGIT local to INT.
> 
> Hi Tim,
> 
> The only problem is that DIGIT is useful for a bunch of rules. :)


INT             : (DIGIT)+ ;
fragment DIGIT  : '0'..'9' ;

-or-

INT             : (DIGIT)+ ;
substring DIGIT : '0'..'9' ;

I like "fragment". 

Micheal
ANTLR/C#





 
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