[antlr-interest] V3 lexer behaviour clarifications

Gavin Lambert antlr at mirality.co.nz
Sat Mar 31 16:09:27 PDT 2007

At 10:42 1/04/2007, you wrote:
 >That says to predict alt 1, FLOAT, if it sees a '.' after the 
 >else do alt 2 (INT).
 >lexer grammar T;
 >FLOAT : INT '.' INT;
 >INT : ('0'..'9')+;
 >Ain't that slick?  Must be something else going on with your

No, you're right, I goofed :)  My real int rule looked like this:

   : '0' ('x' | 'X') HexDigit+
   | '0'
   | ('+' | '-')? NonZeroDigit Digit*

... which of course meant that if the leading digit was a zero 
then it wouldn't match a sign, and of course the input it was 
failing on was "-0.3223e-23".

(I broke the leading-zero case out in the first place because I 
wanted to specifically disallow a 0 followed by other digits.)

Rewriting the last two alts so that both supported signs fixed the 
problem.  Sorry for the noise ;)

More information about the antlr-interest mailing list