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

Terence Parr parrt at cs.usfca.edu
Mon Nov 8 14:34:09 PST 2004



On Nov 8, 2004, at 2:24 PM, micheal_jor wrote:

>
>
> --- 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".

heh, that's not bad!  Or possibly "subphrase" or "phrase"?  "partial"?

fragment is good, actually!

Ter
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!





 
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