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

Unified Diff: src/scanner.cc

Issue 1472323002: [es6] Correct parsing of regular expression literal flags. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix oversight in interpreter Created 5 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
« no previous file with comments | « src/scanner.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('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 f6e354a23c2e91d7fdbdf7c6d6385c9b99421ef9..7c857136e71d4e1eee445235aa7d2f728a3159a5 100644
--- a/src/scanner.cc
+++ b/src/scanner.cc
@@ -1393,20 +1393,41 @@ bool Scanner::ScanRegExpPattern(bool seen_equal) {
}
-bool Scanner::ScanRegExpFlags() {
+Maybe<RegExp::Flags> Scanner::ScanRegExpFlags() {
// Scan regular expression flags.
LiteralScope literal(this);
+ int flags = 0;
while (c0_ >= 0 && unicode_cache_->IsIdentifierPart(c0_)) {
- if (c0_ != '\\') {
- AddLiteralCharAdvance();
- } else {
- return false;
+ RegExp::Flags flag = RegExp::kNone;
+ switch (c0_) {
+ case 'g':
+ flag = RegExp::kGlobal;
+ break;
+ case 'i':
+ flag = RegExp::kIgnoreCase;
+ break;
+ case 'm':
+ flag = RegExp::kMultiline;
+ break;
+ case 'u':
+ if (!FLAG_harmony_unicode_regexps) return Nothing<RegExp::Flags>();
+ flag = RegExp::kUnicode;
+ break;
+ case 'y':
+ if (!FLAG_harmony_regexps) return Nothing<RegExp::Flags>();
+ flag = RegExp::kSticky;
+ break;
+ default:
+ return Nothing<RegExp::Flags>();
}
+ if (flags & flag) return Nothing<RegExp::Flags>();
+ AddLiteralCharAdvance();
+ flags |= flag;
}
literal.Complete();
next_.location.end_pos = source_pos();
- return true;
+ return Just(RegExp::Flags(flags));
}
« no previous file with comments | « src/scanner.h ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698