[antlr-interest] How to get the last token type just recognized in the lexer?
chainone at gmail.com
Fri Nov 21 05:30:57 PST 2008
I am right now using antlr V2 to write a parser.And I meet this
problem,don't know how to fix it.
The problem is:
: '.' (DIGIT)+ (('e' | 'E') ('+' | '-')? (DIGIT)+)?
| '.' ('e' | 'E') ('+' | '-')? (DIGIT)+
I want to match the strings like:
To deal with the case like:"class.e9", ".e9" here could be accepted by FLOAT
rule and ID rule
So it seems that the only solution is to predict the last token just
recognized, if the last token is a INT, then FLOAT rule should be followed.
so I need to know what the last token is.
calling function LA(-1) could do this, however LA(-1) is only available in
parser not in lexer
So...Is there anyone could tell me how to get the last token type
just recognized in the lexer?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest