[antlr-interest] Re: Referencing Tokens in Lexer Rules?
Jason
jasonriz at yahoo.com
Tue Jan 27 08:01:09 PST 2004
Loring,
Okay, I'm finally back to my parser. Thanks for
taking the time to reply. The syntactic predicate
solution would be a good one if it weren't for the
fact that I've actually got a couple of hundred tokens
rather than just a few. Maybe it still is, I'll have
to do some more research. In any case, thinks for the
push in the right direction.
-jason
--- lgcraymer <lgc at mail1.jpl.nasa.gov> wrote:
> What happens is that "foobar" is first identified as
> an "ID" token (or
> whatever you call the rule for matching text
> tokens), then looked up
> in a hash table and assigned the value MYTOKEN.
> There is no mMYTOKEN
> method generated.
>
> You can explicitly identify "foobar" NEWLINE in your
> ID rule using a
> syntactic predicate (relatively low overhead; the
> syntactic predicate
> will only execute if 'f' is matched first at a
> minimum) and then
> assign it a MYRULE token type.
>
> --Loring
>
>
> --- In antlr-interest at yahoogroups.com, Jason
> <jasonriz at y...> wrote:
> > Hello,
> >
> > I'm trying to reference a token in a lexer rule
> and
> > ANTLR is complaining. Imagine I've got this:
> >
> > tokens
> > {
> > MYTOKEN = "foobar";
> > }
> >
> > MYRULE: MYTOKEN NEWLINE
> > ;
> >
> > NEWLINE:
> > '\r' '\n'
> > |
> > '\n'
> > ;
> >
> > When I try to build my lexer ANTLR complains that
> > there is no definition of rule mMYTOKEN. Is there
> > some way to do what I'm trying to do? If not, is
> it
> > because what I"m trying to do doesn't make sense?
> > Thank in advance for any replies!
> >
> > -jason
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Hotjobs: Enter the "Signing Bonus"
> Sweepstakes
> > http://hotjobs.sweepstakes.yahoo.com/signingbonus
>
>
>
>
> 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/
>
>
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/
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