[antlr-interest] [newbie] Lexer Confusion
UW Student
uw.anon at gmail.com
Fri Jul 4 14:06:04 PDT 2008
Hello,
I'm having some trouble understanding the behaviour of Antlr's lexer. I
am quite new to Antlr (having previously focussed on JFlex) so please
excuse me if this is a naive question.
My grammar is as follows
grammar Test;
nonTerm : TERM1 TERM2;
TERM1 : '..'+;
TERM2 : '.';
However, when I try to recognize the string '...' (without the quotes),
AntlrWorks indicates a MismatchedTokenException. (Looking at the
generated code, I believe this is because TERM1 is consuming the third
DOT and then failing to find a fourth.) I do not understand why this is
happening.
The above example is a toy language that I created to try to isolate the
problem I was having. My actual lexer looks more like this:
TERM1 : (' ' | '...')+
TERM2 : '.'
And I would like ' .' to be lexed as [TERM1, TERM2].
Any suggestions would be greatly appreciated.
Thanks,
Andrew
More information about the antlr-interest
mailing list