[antlr-interest] Specifying literals in the Lexer
remi.koutcherawy at wanadoo.fr
Wed Aug 28 13:31:47 PDT 2002
> I really do want to specify one or two of my keywords in the lexer
> instead of the parser. This is because the keywords contain '[', ']'
> characters that are valid characters in my IDENTIFIER expression.
I had the almost same problem parsing Fortran to identify ".EQ." as a token and not
a wrong float number.
I had to declare it as a token AND as a rule in the lexer :
class LexF90 extends Lexer;
k = 3;
EQ = ".eq.";
EQ : ".eq.";
NUM : ('0'..'9')+ ('.' ('0'..'9')*)? (EXPONENT)?
| '.' ('0'..'9')+ (EXPONENT)? ;
protected EXPONENT:('e') ('+'|'-')? ('0'..'9')+;
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest