Chromium Code Reviews| Index: src/scanner.cc |
| diff --git a/src/scanner.cc b/src/scanner.cc |
| index ddcd937584d50fc45fa921a25e2a5d21fcf5697e..9da2756b8b68480ca0bfe4446b7a26c03308b604 100644 |
| --- a/src/scanner.cc |
| +++ b/src/scanner.cc |
| @@ -694,7 +694,7 @@ bool Scanner::ScanEscape() { |
| case 'r' : c = '\r'; break; |
| case 't' : c = '\t'; break; |
| case 'u' : { |
| - c = ScanHexNumber(4); |
| + c = ScanUnicodeEscape(); |
| if (c < 0) return false; |
| break; |
| } |
| @@ -887,7 +887,28 @@ uc32 Scanner::ScanIdentifierUnicodeEscape() { |
| Advance(); |
| if (c0_ != 'u') return -1; |
| Advance(); |
| - return ScanHexNumber(4); |
| + return ScanUnicodeEscape(); |
| +} |
| + |
| + |
| +uc32 Scanner::ScanUnicodeEscape() { |
| + // Accept both \uxxxx and \u{xxxx}. \ and u have already been read. |
| + bool has_brace = false; |
| + if (c0_ == '{') { |
| + has_brace = true; |
| + Advance(); |
| + } |
| + uc32 c = ScanHexNumber(4); |
|
arv (Not doing code reviews)
2014/11/07 16:23:20
In case of u{ then there is no upper limit for the
caitp (gmail)
2014/11/07 16:23:55
If `has_brace` is true, we want the HexDigits non-
marja
2014/11/13 11:53:20
Done.
|
| + if (c < 0) { |
| + return c; |
| + } |
| + if (has_brace) { |
| + if (c0_ != '}') { |
| + return 1; |
|
caitp (gmail)
2014/11/07 16:50:39
shouldn't this return -1 so that the scanner knows
marja
2014/11/13 11:53:20
Done.
|
| + } |
| + Advance(); |
| + } |
| + return c; |
| } |