Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1209)

Unified Diff: src/scanner.cc

Issue 706263002: Implement ES6 unicode escapes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: . Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
« no previous file with comments | « src/scanner.h ('k') | test/cctest/test-parsing.cc » ('j') | test/cctest/test-parsing.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698