[antlr-interest] Lexing problem - range of ints vs float

kjam pohilets at gmail.com
Tue Sep 11 08:55:11 PDT 2012


Hi, All!

I want lexer to interpret input '0..5' as sequence of tokens INT, '..', INT.
But instead it sees '0.' and tries to continue parsing float and fails. I
have '..' token implicitly defined in parser grammar and following lexer
rules for INT and FLOAT:

INT
    : ('0d')? '0'..'9'+
    | '0b' '0'..'1'+
    | '0c' '0'..'7'+
    | '0x' HEX_DIGIT+
    ;

FLOAT
    : ('0'..'9')+ '.' ('0'..'9')+ EXPONENT?
    | ('0'..'9')+ EXPONENT
    ;

fragment
EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ;

fragment
HEX_DIGIT : ('0'..'9'|'a'..'f'|'A'..'F') ;



--
View this message in context: http://antlr.1301665.n2.nabble.com/Lexing-problem-range-of-ints-vs-float-tp7578705.html
Sent from the ANTLR mailing list archive at Nabble.com.


More information about the antlr-interest mailing list