| Index: src/scanner.cc
|
| ===================================================================
|
| --- src/scanner.cc (revision 6635)
|
| +++ src/scanner.cc (working copy)
|
| @@ -516,17 +516,30 @@
|
|
|
| Token::Value JsonScanner::ScanJsonNumber() {
|
| LiteralScope literal(this);
|
| - if (c0_ == '-') AddLiteralCharAdvance();
|
| + bool negative = false;
|
| +
|
| + if (c0_ == '-') {
|
| + AddLiteralCharAdvance();
|
| + negative = true;
|
| + }
|
| if (c0_ == '0') {
|
| AddLiteralCharAdvance();
|
| // Prefix zero is only allowed if it's the only digit before
|
| // a decimal point or exponent.
|
| if ('0' <= c0_ && c0_ <= '9') return Token::ILLEGAL;
|
| } else {
|
| + int i = 0;
|
| + int digits = 0;
|
| if (c0_ < '1' || c0_ > '9') return Token::ILLEGAL;
|
| do {
|
| + i = i * 10 + c0_ - '0';
|
| + digits++;
|
| AddLiteralCharAdvance();
|
| } while (c0_ >= '0' && c0_ <= '9');
|
| + if (c0_ != '.' && c0_ != 'e' && c0_ != 'E' && digits < 10) {
|
| + number_ = (negative ? -i : i);
|
| + return Token::NUMBER;
|
| + }
|
| }
|
| if (c0_ == '.') {
|
| AddLiteralCharAdvance();
|
| @@ -544,6 +557,10 @@
|
| } while (c0_ >= '0' && c0_ <= '9');
|
| }
|
| literal.Complete();
|
| + ASSERT_NOT_NULL(next_.literal_chars);
|
| + number_ = StringToDouble(next_.literal_chars->ascii_literal(),
|
| + NO_FLAGS, // Hex, octal or trailing junk.
|
| + OS::nan_value());
|
| return Token::NUMBER;
|
| }
|
|
|
|
|