[antlr-interest] distinguishing between int and double in a tree grammar

Michael Bedward michael.bedward at gmail.com
Mon Mar 16 06:03:46 PDT 2009


Hi Anders,

This is how I distinguish between int and double in my lexer rules:

INT_LITERAL	: '0' | NonZeroDigit Digit*
		;

FLOAT_LITERAL	: ('0' | NonZeroDigit Digit*)? Dot Digit* FloatExp?
		;
fragment
Digit           : '0'..'9'
                ;

fragment
Dot             : '.'
                ;

fragment
NonZeroDigit    : '1'..'9'
                ;

fragment
FloatExp        : ('e'|'E' (PLUS|MINUS)? '0'..'9'+)
                ;

Hope this helps
Michael


More information about the antlr-interest mailing list