[antlr-interest] More on FLOAT and INT

Subhobroto Sinha subhobrotosinha at rediffmail.com
Tue Jul 5 12:22:44 PDT 2005


  
While browsing through the examples, I came across this definition in IDL.G :

//////////////
INT
options {
  paraphrase = "an integer value";
}
	: (DIGIT)+                  // base-10
      (  '.' (DIGIT)* 	{$setType(FLOAT);}
	  (('e' | 'E') ('+' | '-')? (DIGIT)+)?
	  | ('e' | 'E') ('+' | '-')? (DIGIT)+ {$setType(FLOAT);}
      )?
	;

FLOAT
options {
  paraphrase = "an floating point value";
}

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

protected
DIGIT
options {
  paraphrase = "a digit";
}
	:	'0'..'9'
	;
//////////////

As far as I can follow, this exactly parses all C/C++ type floating and integer values.
However, the rules are inadequate in parsing floating point numbers in other languages like Java.

I just wanna know if I am wrong. All my numbers are in base 10 (I will allow other bases, except 2, eventually)

Regards

Subhobroto Sinha
http://www.geocities.com/subhobrotosinha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050705/4b15cc08/attachment.html


More information about the antlr-interest mailing list