# HG changeset patch # User aziz # Date 1183103525 0 # Node ID 512cd2248dfc4559408dbf9ba7b83dc5ef764662 # Parent 32cc23bd217bac6220036c9b5b7c52a87e1732c2 - Fix: issueing error on hexadecimal number overflow. diff -r 32cc23bd217b -r 512cd2248dfc trunk/src/Lexer.d --- a/trunk/src/Lexer.d Fri Jun 29 06:27:04 2007 +0000 +++ b/trunk/src/Lexer.d Fri Jun 29 07:52:05 2007 +0000 @@ -891,7 +891,7 @@ Suffix:= (L|[uU]|L[uU]|[uU]L)? HexDigits:= [0-9a-zA-Z_]+ - FloatLiteral:= Float([fFL]|i|[fFL]i)? + FloatLiteral:= Float[fFL]?i? Float:= DecFloat | HexFloat DecFloat:= ([0-9][0-9_]*[.]([0-9_]*DecExponent?)?) | [.][0-9][0-9_]*DecExponent? | [0-9][0-9_]*DecExponent DecExponent:= [eE][+-]?[0-9_]+ @@ -955,6 +955,7 @@ break; } + // The number could be a float, so check overflow below. switch (*p) { case '.': @@ -976,20 +977,12 @@ goto Lfinalize; LscanHex: - digits = 16; + assert(digits == 0); while (ishexad(*++p)) { if (*p == '_') continue; - - if (--digits == 0) - { - // Overflow: skip following digits. - overflow = true; - while (ishexad(*++p)) {} - break; - } - + ++digits; ulong_ *= 16; if (*p <= '9') ulong_ += *p - '0'; @@ -999,9 +992,16 @@ ulong_ += *p - 'a' + 10; } - if (digits == 16) + if (digits == 0) error(MID.NoDigitsInHexNumber); + if (digits > 16) + { + // Overflow: skip following digits. + error(MID.OverflowHexNumber); + while (ishexad(*++p)) {} + } + switch (*p) { case '.':