Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index 7236cb42cc01e418d16814efc2789b6f2a2e83aa..4c8f4979360e4aad11b672cea6022a45b38189ee 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -527,7 +527,7 @@ class RegExpParser { |
| void Advance(int dist); |
| void Reset(int pos); |
| - bool HasCharacterEscapes(); |
| + bool IsNonSimple(); |
|
Christian Plesner Hansen
2008/12/12 09:52:01
You should generally avoid negative method names.
|
| int captures_started() { return captures_ == NULL ? 0 : captures_->length(); } |
| int position() { return next_pos_ - 1; } |
| @@ -548,7 +548,7 @@ class RegExpParser { |
| int next_pos_; |
| FlatStringReader* in_; |
| Handle<String>* error_; |
| - bool has_character_escapes_; |
| + bool non_simple_; |
|
Christian Plesner Hansen
2008/12/12 09:52:01
Ditto.
|
| ZoneList<RegExpCapture*>* captures_; |
| bool is_scanned_for_captures_; |
| // The capture count is only valid after we have scanned for captures. |
| @@ -3502,7 +3502,7 @@ RegExpParser::RegExpParser(FlatStringReader* in, |
| next_pos_(0), |
| in_(in), |
| error_(error), |
| - has_character_escapes_(false), |
| + non_simple_(false), |
| captures_(NULL), |
| is_scanned_for_captures_(false), |
| capture_count_(0), |
| @@ -3550,11 +3550,10 @@ void RegExpParser::Advance(int dist) { |
| } |
| -// 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_; |
| +// 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 RegExpParser::IsNonSimple() { |
|
Christian Plesner Hansen
2008/12/12 09:52:01
This should be a simple accessor, not a full camel
|
| + return non_simple_; |
| } |
| RegExpTree* RegExpParser::ReportError(Vector<const char> message) { |
| @@ -3769,7 +3768,7 @@ RegExpTree* RegExpParser::ParseDisjunction() { |
| Advance(2); |
| break; |
| } |
| - has_character_escapes_ = true; |
| + non_simple_ = true; |
| break; |
| case '{': { |
| int dummy; |
| @@ -3822,6 +3821,7 @@ RegExpTree* RegExpParser::ParseDisjunction() { |
| is_greedy = false; |
| Advance(); |
| } |
| + non_simple_ = true; // Adding quantifier might *remove* look-ahead. |
| builder.AddQuantifierToAtom(min, max, is_greedy); |
| } |
| } |
| @@ -4314,7 +4314,7 @@ bool ParseRegExp(FlatStringReader* input, |
| } else { |
| ASSERT(result->tree != NULL); |
| ASSERT(result->error.is_null()); |
| - result->has_character_escapes = parser.HasCharacterEscapes(); |
| + result->non_simple = parser.IsNonSimple(); |
| result->capture_count = parser.captures_started(); |
| } |
| return !parser.failed(); |