[antlr-interest] Lexer Compiles in 4.0 but not in 3.4
Hans Uhlig
huhlig at uhlisys.com
Mon Jan 30 15:56:15 PST 2012
Hi all, I am a bit confused. My Lexer Grammar seems to compile fine in
antlr 4.0 but seems to have trouble in 3.4 Perhaps I am being daft but I
cant for the life of me figure out why.
error(208): essex_lexer.g:23:1: The following token definitions can never
be matched because prior tokens match the same input:
BININT,OCTINT,DECINT,HEXINT
http://pastebin.com/FUWQjpvj
lexer grammar essex_lexer;
ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ;
INT : BININT
| OCTINT
| DECINT
| HEXINT
;
BININT : '0b' BIN_DIGIT+
;
OCTINT : '0o' OCT_DIGIT+
;
DECINT : DIGIT+
;
HEXINT : '0x' HEX_DIGIT+
;
FLOAT : DIGIT+ '.' DIGIT+ EXPONENT?
| DIGIT+ EXPONENT
| DIGIT+ 'f'
;
fragment
BIN_DIGIT
: ('0' | '1')
;
fragment
OCT_DIGIT
: ('0'..'7')
;
fragment
DIGIT
: ('0'..'9')
;
fragment
HEX_DIGIT
: (DIGIT | 'a'..'f' | 'A'..'F')
;
fragment
EXPONENT: ('e'|'E') ('+'|'-')? DIGIT+ ;
WS : ( ' ' | '\t' | '\r' | '\n' ) {$channel=HIDDEN;} ;
STRING : '"' ( ESC_SEQ | ~('\\'|'"') )* '"' ;
CHAR : '\''( ESC_SEQ | ~('\''|'\\')) '\'' ;
fragment
ESC_SEQ : '\\' ('\\'|'\''|'\"'|'a'|'b'|'f'|'n'|'r'|'t'|'v') | OCT_ESC |
HEX_ESC | UNICODE_ESC ;
fragment
HEX_ESC : '\\x' HEX_DIGIT HEX_DIGIT ;
fragment
OCT_ESC
: '\\' ('0'..'3') ('0'..'7') ('0'..'7')
| '\\' ('0'..'7') ('0'..'7')
| '\\' ('0'..'7')
;
fragment
UNICODE_ESC
: '\\u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
| '\\U' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT
HEX_DIGIT HEX_DIGIT HEX_DIGIT
;
More information about the antlr-interest
mailing list