Chromium Code Reviews| Index: src/parsing/scanner.cc |
| diff --git a/src/parsing/scanner.cc b/src/parsing/scanner.cc |
| index faec88b8a4bfb5ff37bf8dad58fefc32cd8ff03f..e8e77b9ed6956f63822015c35c979a4afe646610 100644 |
| --- a/src/parsing/scanner.cc |
| +++ b/src/parsing/scanner.cc |
| @@ -976,9 +976,11 @@ Token::Value Scanner::ScanNumber(bool seen_period) { |
| DCHECK(IsDecimalDigit(c0_)); // the first digit of the number or the fraction |
| enum { DECIMAL, HEX, OCTAL, IMPLICIT_OCTAL, BINARY } kind = DECIMAL; |
| + bool decimal_that_looks_like_octal = false; |
| LiteralScope literal(this); |
| bool at_start = !seen_period; |
| + int start_pos = source_pos(); // For reporting octal positions. |
| if (seen_period) { |
| // we have already seen a decimal point of the float |
| AddLiteralChar('.'); |
| @@ -987,7 +989,6 @@ Token::Value Scanner::ScanNumber(bool seen_period) { |
| } else { |
| // if the first character is '0' we must check for octals and hex |
| if (c0_ == '0') { |
| - int start_pos = source_pos(); // For reporting octal positions. |
|
caitp (gmail)
2016/05/05 18:25:02
This change seems not to be needed, since it's irr
jwolfe
2016/05/05 18:42:02
I can leave the local variable uninitialized until
|
| AddLiteralCharAdvance(); |
| // either 0, 0exxx, 0Exxx, 0.xxx, a hex number, a binary number or |
| @@ -1030,6 +1031,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) { |
| if (c0_ == '8' || c0_ == '9') { |
| at_start = false; |
| kind = DECIMAL; |
| + decimal_that_looks_like_octal = true; |
|
caitp (gmail)
2016/05/05 18:21:08
'8' and '9' are decidedly not octal digits --- why
|
| break; |
| } |
| if (c0_ < '0' || '7' < c0_) { |
| @@ -1039,6 +1041,8 @@ Token::Value Scanner::ScanNumber(bool seen_period) { |
| } |
| AddLiteralCharAdvance(); |
| } |
| + } else if (c0_ == '8' || c0_ == '9') { |
| + decimal_that_looks_like_octal = true; |
| } |
| } |
| @@ -1060,6 +1064,8 @@ Token::Value Scanner::ScanNumber(bool seen_period) { |
| literal.Complete(); |
| HandleLeadSurrogate(); |
| + if (decimal_that_looks_like_octal) |
|
caitp (gmail)
2016/05/05 18:25:02
`decimal_that_looks_like_octal` is always false un
jwolfe
2016/05/05 18:42:01
I was surprised by needing two different checks in
|
| + octal_pos_ = Location(start_pos, source_pos()); |
| return Token::SMI; |
| } |
| HandleLeadSurrogate(); |
| @@ -1098,6 +1104,8 @@ Token::Value Scanner::ScanNumber(bool seen_period) { |
| literal.Complete(); |
| + if (decimal_that_looks_like_octal) |
| + octal_pos_ = Location(start_pos, source_pos()); |
|
caitp (gmail)
2016/05/06 21:08:03
So, if we want to have a different error message f
|
| return Token::NUMBER; |
| } |