[antlr-interest] How to modify this rule?

chain one chainone at gmail.com
Mon Jan 5 19:44:04 PST 2009


enumeration_type
: DOT IDENT DOT
;

DOT
: '.'
;
fragment
DIGIT
: '0'..'9'
;

INT
  : '-'? DIGIT+
 ;

FLOAT
:   '.' DIGIT* EXPONENT?
     ;

fragment
EXPONENT: ('e' | 'E') ('+' | '-')? (DIGIT)+;



IDENT

: ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'_'|'0'..'9')*
;

when the input is ".EXTERNAL." , the lexer don't recognize '.' as a DOT but
try to recognize it as a FLOAT. it will fail after ".E" has been recognized.


How to make the lexer capable of back track? That is also to say if it fails
to recognize a FLOAT, it will try DOT.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090106/fa692806/attachment.html 


More information about the antlr-interest mailing list