[antlr-interest] Re: "protected" lexer rules
Tim Simpson
tim at monster-works.co.nz
Mon Nov 8 12:51:17 PST 2004
> > --- In antlr-interest at yahoogroups.com, "John B. Brodie" <jbb at a...>
> > wrote:
> >> On Sun, 07 Nov 2004 15:47:57, John D. Mitchell wrote:
> >>>> perhaps there is a different "section"; one for regular rules and
> > then
> >>>> one for these shared rules?
> >>>
> >>> Naw, I prefer to have the helper rules next to the rule that they
> >>> help.
> >>
> >
> > I like "local", "local-rule" or "local-scope" for some reason.
>
> Hi. Local makes sense too actually. It's definitely not overloaded in
> the grammar name space, but it too has a meaning as in "local
> variable". Hmm...it's good actually. subrule is very specific, but is
> an overloaded term. Damn!
>
> INT : (DIGIT)+ ;
>
> local
> DIGIT : '0'..'9' ;
>
> Hmm..not bad.
>
> Ter
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.
Thanks for listening,
Tim.
--
Tim Simpson, Ph.D
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