# HG changeset patch # User aziz # Date 1183034825 0 # Node ID c0f1c8be3a471ef47bf0c48d73bab8da4279bd2a # Parent 63af7ddf52e193630883f73806bc00d26da6df4f - Added code for converting hex characters to binary numbers. diff -r 63af7ddf52e1 -r c0f1c8be3a47 trunk/src/Lexer.d --- a/trunk/src/Lexer.d Thu Jun 28 12:31:00 2007 +0000 +++ b/trunk/src/Lexer.d Thu Jun 28 12:47:05 2007 +0000 @@ -911,6 +911,7 @@ ulong ulong_; bool overflow; + size_t digits; if (*p != '0') goto LscanInteger; @@ -974,12 +975,29 @@ goto Lfinalize; LscanHex: + digits = 16; while (ishexad(*++p)) { if (*p == '_') continue; - // todo + + if (--digits == 0) + { + // Overflow: skip following digits. + overflow = true; + while (ishexad(*++p)) {} + break; + } + + ulong_ *= 16; + if (*p <= '9') + ulong_ += *p - '0'; + else if (*p <= 'F') + ulong_ += *p - 'A' + 10; + else + ulong_ += *p - 'a' + 10; } + switch (*p) { case '.': @@ -995,7 +1013,7 @@ goto Lfinalize; LscanBin: - size_t digits; + assert(digits == 0); while (1) { if (*++p == '0')