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

Unified Diff: src/parser.cc

Issue 40103: Fix issue 246. (Closed)
Patch Set: 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 | « no previous file | test/mjsunit/regress/regress-246.js » ('j') | test/mjsunit/regress/regress-246.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 713c6a809e3dc34cf245254f8fc38397313345ad..115e1819f703168708f3c4b4af61fa9718fdcf85 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -3606,7 +3606,7 @@ RegExpParser::RegExpParser(FlatStringReader* in,
next_pos_(0),
in_(in),
error_(error),
- simple_(true),
+ simple_(false),
contains_anchor_(false),
captures_(NULL),
is_scanned_for_captures_(false),
@@ -3676,6 +3676,11 @@ RegExpTree* RegExpParser::ParsePattern() {
if (has_more()) {
ReportError(CStrVector("Unmatched ')'") CHECK_FAILED);
}
+ // If the result of parsing is a literal string atom, and it has the
+ // same length as the input, then the atom is identical to the input.
+ if (result->IsAtom() && result->AsAtom()->length() == in()->length()) {
+ simple_ = true;
+ }
return result;
}
@@ -3875,7 +3880,6 @@ RegExpTree* RegExpParser::ParseDisjunction() {
Advance(2);
break;
}
- simple_ = false;
break;
case '{': {
int dummy;
@@ -3932,7 +3936,6 @@ RegExpTree* RegExpParser::ParseDisjunction() {
is_greedy = false;
Advance();
}
- simple_ = false; // Adding quantifier might *remove* look-ahead.
builder.AddQuantifierToAtom(min, max, is_greedy);
}
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-246.js » ('j') | test/mjsunit/regress/regress-246.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698