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

Unified Diff: src/parser.cc

Issue 14886: Bring toiger up to date with bleeding edge 984. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: Created 12 years 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.h ('k') | src/regexp-macro-assembler-ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.cc
===================================================================
--- src/parser.cc (revision 1004)
+++ src/parser.cc (working copy)
@@ -527,7 +527,9 @@
void Advance(int dist);
void Reset(int pos);
- bool HasCharacterEscapes();
+ // Reports whether the pattern might be used as a literal search string.
+ // Only use if the result of the parse is a single atom node.
+ bool simple();
int captures_started() { return captures_ == NULL ? 0 : captures_->length(); }
int position() { return next_pos_ - 1; }
@@ -548,7 +550,7 @@
int next_pos_;
FlatStringReader* in_;
Handle<String>* error_;
- bool has_character_escapes_;
+ bool simple_;
ZoneList<RegExpCapture*>* captures_;
bool is_scanned_for_captures_;
// The capture count is only valid after we have scanned for captures.
@@ -3501,7 +3503,7 @@
next_pos_(0),
in_(in),
error_(error),
- has_character_escapes_(false),
+ simple_(true),
captures_(NULL),
is_scanned_for_captures_(false),
capture_count_(0),
@@ -3549,11 +3551,8 @@
}
-// Reports whether the parsed string atoms contain any characters that were
-// escaped in the original pattern. If not, all atoms are proper substrings
-// of the original pattern.
-bool RegExpParser::HasCharacterEscapes() {
- return has_character_escapes_;
+bool RegExpParser::simple() {
+ return simple_;
}
RegExpTree* RegExpParser::ReportError(Vector<const char> message) {
@@ -3768,7 +3767,7 @@
Advance(2);
break;
}
- has_character_escapes_ = true;
+ simple_ = false;
break;
case '{': {
int dummy;
@@ -3821,6 +3820,7 @@
is_greedy = false;
Advance();
}
+ simple_ = false; // Adding quantifier might *remove* look-ahead.
builder.AddQuantifierToAtom(min, max, is_greedy);
}
}
@@ -4301,20 +4301,22 @@
bool ParseRegExp(FlatStringReader* input,
bool multiline,
- RegExpParseResult* result) {
+ RegExpCompileData* result) {
ASSERT(result != NULL);
// Make sure we have a stack guard.
StackGuard guard;
RegExpParser parser(input, &result->error, multiline);
- result->tree = parser.ParsePattern();
+ RegExpTree* tree = parser.ParsePattern();
if (parser.failed()) {
- ASSERT(result->tree == NULL);
+ ASSERT(tree == NULL);
ASSERT(!result->error.is_null());
} else {
- ASSERT(result->tree != NULL);
+ ASSERT(tree != NULL);
ASSERT(result->error.is_null());
- result->has_character_escapes = parser.HasCharacterEscapes();
- result->capture_count = parser.captures_started();
+ result->tree = tree;
+ int capture_count = parser.captures_started();
+ result->simple = tree->IsAtom() && parser.simple() && capture_count == 0;
+ result->capture_count = capture_count;
}
return !parser.failed();
}
« no previous file with comments | « src/parser.h ('k') | src/regexp-macro-assembler-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698