[antlr-interest] A very basic grammar--and I'm confused!
Richard Steele
rich at steelezone.net
Sat Aug 16 19:42:16 PDT 2008
I'm missing something really basic here and would appreciate some help. I'm not
new to the subject--but it has been a few years and I must have forgotten
everything I (thought?) I knew.
I have a really simple grammar:
grammar R;
r : 'X' ID;
ID : 'A'..'Z'+;
However, this returns a MismatchedTokenException for every (alphabetic) input.
It appears that the 'X' is getting greedily swallowed by the expression for ID,
but I don't understand why that would be, nor how to prevent it from happening.
(If I change the 'X' to '1', or anything else not in ID, then it works as I
expect.)
Can anyone (gently) help?
Thanks,
Rich
More information about the antlr-interest
mailing list