[antlr-interest] Re: Referencing Tokens in Lexer Rules?
lgcraymer
lgc at mail1.jpl.nasa.gov
Tue Jan 20 17:28:07 PST 2004
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/
More information about the antlr-interest
mailing list