24 Dec 2013, 01:53
Pictureofme_pragsmall

Mike Cargal (1 post)

Since INT does not allow for leading zeroes, it does not seem like it is a valid fragment for the decimal portion of the NUMBER token. As a result, I don’t believe it would accept a value like 1.001

NUMBER​​
   :   '-'? INT '.' INT EXP?   // 1.35, 1.35E-9, 0.3, -4.5​​
   |   '-'? INT EXP            // 1e10 -3e4​​
   |   '-'? INT                // -3, 45​​
   ;​​
   fragment INT :   '0' | [1-9] [0-9]* ; // no leading zeros​​             ​​fragment EXP :   [Ee] [+\-]? INT ; // \- since - means "range" inside [...]”
28 Jan 2014, 01:39
Australia-3_pragsmall

Terence Parr (36 posts)

Hi. You’re right! From our grammars-g4/json dir you can grab a diff version. it says:

fragment
INT
	: '0'..'9'+
;

NUMBER
	: '-'? ('0' | ( '1'..'9' INT* )) ('.' INT+)? EXPONENT?
;
  You must be logged in to comment