[antlr-interest] Handling number Integer and real

Peizhao peizhao at itee.uq.edu.au
Thu Aug 17 19:16:48 PDT 2006


Hi All, 

I am new to antlr. I stuck with defining rules for numbers, such as
integer and real.

I defined the following rules. however, it gives warnings when I compile
them.

Rules:
==============================================
INTEGER		:	('+'|'-')? ('0'..'9')+ ;
HEX_INTEGER	:	'0' ('x'|'X') ('0'..'9'|'A'..'F'|'a'..'f')+ ;
BINARY_INTEGER	:	'0' ('b'|'B') ('0'..'9')+ ;
REAL		:	('+'|'-')? ( ('0'..'9')+ (('e'|'E') ('-'|'+')? ('0'..'9')+) |
(('0'..'9')+ '.' ('0'..'9')* (('e'|'E')('-'|'+')? ('0'..'9')+)?) ) |
( '.' ('0'..'9')+ (('e'|'E') ('-'|'+')? ('0'..'9')+)? );


Warnings:
=============================================
lexical nondeterminism between alts 1 and 2 of block upon k==1:'0'..'9'
k==2:'0'..'9' k==3:'0'..'9','E','e'	

lexical nondeterminism between rules INTEGER and REAL upon
k==1:'+','-','0'..'9' k==2:'0'..'9' k==3:<end-of-token>,'0'..'9'


-- 
Regards;

Peizhao



More information about the antlr-interest mailing list