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

Unified Diff: src/regexp/regexp-parser.cc

Issue 2780173002: [regexp] Add support for dotAll flag (Closed)
Patch Set: Address comments Created 3 years, 9 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/regexp/regexp-parser.h ('k') | test/mjsunit/harmony/regexp-dotall.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp/regexp-parser.cc
diff --git a/src/regexp/regexp-parser.cc b/src/regexp/regexp-parser.cc
index 33a16ef01fb2637c402d84a677c9feb3662f8fe3..b145505477bbc87f71458368e60c2336c9985585 100644
--- a/src/regexp/regexp-parser.cc
+++ b/src/regexp/regexp-parser.cc
@@ -29,6 +29,7 @@ RegExpParser::RegExpParser(FlatStringReader* in, Handle<String>* error,
named_back_references_(NULL),
in_(in),
current_(kEndMarker),
+ dotall_(flags & JSRegExp::kDotAll),
ignore_case_(flags & JSRegExp::kIgnoreCase),
multiline_(flags & JSRegExp::kMultiline),
unicode_(flags & JSRegExp::kUnicode),
@@ -40,6 +41,7 @@ RegExpParser::RegExpParser(FlatStringReader* in, Handle<String>* error,
contains_anchor_(false),
is_scanned_for_captures_(false),
failed_(false) {
+ DCHECK_IMPLIES(dotall(), FLAG_harmony_regexp_dotall);
Advance();
}
@@ -270,10 +272,18 @@ RegExpTree* RegExpParser::ParseDisjunction() {
}
case '.': {
Advance();
- // everything except \x0a, \x0d, \u2028 and \u2029
ZoneList<CharacterRange>* ranges =
new (zone()) ZoneList<CharacterRange>(2, zone());
- CharacterRange::AddClassEscape('.', ranges, false, zone());
+
+ if (dotall()) {
+ // Everything.
+ DCHECK(FLAG_harmony_regexp_dotall);
+ CharacterRange::AddClassEscape('*', ranges, false, zone());
+ } else {
+ // Everything except \x0a, \x0d, \u2028 and \u2029
+ CharacterRange::AddClassEscape('.', ranges, false, zone());
+ }
+
RegExpCharacterClass* cc =
new (zone()) RegExpCharacterClass(ranges, false);
builder->AddCharacterClass(cc);
« no previous file with comments | « src/regexp/regexp-parser.h ('k') | test/mjsunit/harmony/regexp-dotall.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698