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:
Lexer rule:
INT
: (DIGIT)+
;
FLOAT
: '.' (DIGIT)+ (('e' | 'E') ('+' | '-')? (DIGIT)+)?
| '.' ('e' | 'E') ('+' | '-')? (DIGIT)+
;
DIGIT
: '0'..'9'
;
I want to match the strings like:
0.1E-10
0.1e+1
0.0
0.E14
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?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---
List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org:8080/mailman/options/antlr-interest/your-email-address