[antlr-interest] Newby Lexer Question
John B. Brodie
jbb at acm.org
Fri Dec 3 07:41:43 PST 2010
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