[antlr-interest] Newby Lexer Question
Daniel Rippel
drippel at yahoo.com
Fri Dec 3 07:51:08 PST 2010
Sorry for the spam.
I originally started with someone else's grammar file.
The issue wasn't my rules.
The issue was a "k=4;" look ahead in my options section.
I kept deleting everything out and found the issue.
----- Original Message ----
From: John B. Brodie <jbb at acm.org>
To: Daniel Rippel <drippel at yahoo.com>
Cc: antlr-interest at antlr.org
Sent: Fri, December 3, 2010 10:41:43 AM
Subject: Re: [antlr-interest] Newby Lexer Question
Greetings!
On Fri, 2010-12-03 at 07:05 -0800, Daniel Rippel wrote:
>
> I am fairly new to antlr and am running into a basic issue that I can't quite
> find the answer for on the wiki and in Parr's book.
>
> Here is my lexer. Greatly simplified of course.
>
> ...
> CREATE : 'create' ;
> ...
> IDENTIFIER : (['a'..'z']|['A'..'Z'])(['a'..'z']|['A'..'Z']|['0'..'9'])+ ;
>
did you really mean to use the [ and ] above? those aren't valid syntax
here. [] are used to surround parameters being passed to a rule. use ()
instead...
> Basically, I want 'create' to be a keyword token.
> And something like 'createFoo' should be an identifier.
>
> However, the lexer always finds 'create' stops and gives me the CREATE token
> back.
>
> I have tried using the greedy flag but am not having any luck.
>
> Any ideas or suggestions would be extremely helpful.
> I'll even accept an RTFM, if you can point me to the page in the FM.
>
once you replace the [] with () i see no problem with this fragment.
maybe try to create the smallest (yet complete) grammar that exhibits
your problem. and post that.
sorry for not being very helpful....
-jbb
More information about the antlr-interest
mailing list