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

Unified Diff: src/scanner.cc

Issue 20260: Issue 87: Allow unicode escapes in regexp flags. (Closed)
Patch Set: Now with test Created 11 years, 10 months 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
« no previous file with comments | « src/parser.cc ('k') | test/mjsunit/regress/regress-87.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/scanner.cc
diff --git a/src/scanner.cc b/src/scanner.cc
index 8585e3836ecbf2a6663c4d88b37f337ff8b2a8eb..65ec0f8b7af0301becebfd74b70f3371f0c322a9 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -384,7 +384,7 @@ uc32 Scanner::ScanHexEscape(uc32 c, int length) {
for (int j = i-1; j >= 0; j--) {
PushBack(digits[j]);
}
-
+ // Notice: No handling of error - treat it as "\u"->"u".
return c;
}
x = x * 16 + d;
@@ -829,8 +829,18 @@ bool Scanner::ScanRegExpPattern(bool seen_equal) {
bool Scanner::ScanRegExpFlags() {
// Scan regular expression flags.
StartLiteral();
- while (kIsIdentifierPart.get(c0_))
+ while (kIsIdentifierPart.get(c0_)) {
+ if (c0_ == '\\') {
+ uc32 c = ScanIdentifierUnicodeEscape();
+ if (c != static_cast<uc32>(unibrow::Utf8::kBadChar)) {
+ // We allow any escaped character, unlike the restriction on
+ // IdentifierPart when it is used to build an IdentifierName.
+ AddChar(c);
+ continue;
+ }
+ }
AddCharAdvance();
+ }
TerminateLiteral();
next_.location.end_pos = source_pos() - 1;
« no previous file with comments | « src/parser.cc ('k') | test/mjsunit/regress/regress-87.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698