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

Unified Diff: src/parser.h

Issue 1418963009: Experimental support for RegExp lookbehind. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixed test cases 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/flag-definitions.h ('k') | src/parser.cc » ('j') | src/regexp/jsregexp.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index b674a9d2e2323d8014edceab988c52474e0c6ca3..ac2a77bec8c1abc3274da898c9d7ff42e695a63b 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -370,7 +370,7 @@ class BufferedZoneList {
// Accumulates RegExp atoms and assertions into lists of terms and alternatives.
class RegExpBuilder: public ZoneObject {
public:
- explicit RegExpBuilder(Zone* zone);
+ RegExpBuilder(Zone* zone, RegExpTree::ReadDirection read_direction);
void AddCharacter(uc16 character);
// "Adds" an empty expression. Does nothing except consume a
// following quantifier
@@ -394,6 +394,7 @@ class RegExpBuilder: public ZoneObject {
BufferedZoneList<RegExpTree, 2> terms_;
BufferedZoneList<RegExpTree, 2> text_;
BufferedZoneList<RegExpTree, 2> alternatives_;
+ RegExpTree::ReadDirection read_direction_;
#ifdef DEBUG
enum {ADD_NONE, ADD_CHAR, ADD_TERM, ADD_ASSERT, ADD_ATOM} last_added_;
#define LAST(x) last_added_ = x;
@@ -415,7 +416,7 @@ class RegExpParser BASE_EMBEDDED {
RegExpTree* ParsePattern();
RegExpTree* ParseDisjunction();
RegExpTree* ParseGroup();
- RegExpTree* ParseCharacterClass();
+ RegExpTree* ParseCharacterClass(RegExpTree::ReadDirection read_direction);
// Parses a {...,...} quantifier and stores the range in the given
// out parameters.
@@ -450,7 +451,7 @@ class RegExpParser BASE_EMBEDDED {
bool simple();
bool contains_anchor() { return contains_anchor_; }
void set_contains_anchor() { contains_anchor_ = true; }
- int captures_started() { return captures_ == NULL ? 0 : captures_->length(); }
+ int captures_started() { return captures_started_; }
int position() { return next_pos_ - 1; }
bool failed() { return failed_; }
@@ -472,11 +473,12 @@ class RegExpParser BASE_EMBEDDED {
public:
RegExpParserState(RegExpParserState* previous_state,
SubexpressionType group_type,
- int disjunction_capture_index,
- Zone* zone)
+ RegExpTree::ReadDirection read_direction,
+ int disjunction_capture_index, Zone* zone)
: previous_state_(previous_state),
- builder_(new(zone) RegExpBuilder(zone)),
+ builder_(new (zone) RegExpBuilder(zone, read_direction)),
group_type_(group_type),
+ read_direction_(read_direction),
disjunction_capture_index_(disjunction_capture_index) {}
// Parser state of containing expression, if any.
RegExpParserState* previous_state() { return previous_state_; }
@@ -485,6 +487,8 @@ class RegExpParser BASE_EMBEDDED {
RegExpBuilder* builder() { return builder_; }
// Type of regexp being parsed (parenthesized group or entire regexp).
SubexpressionType group_type() { return group_type_; }
+ // Lookahead or Lookbehind.
+ RegExpTree::ReadDirection read_direction() { return read_direction_; }
// Index in captures array of first capture in this sub-expression, if any.
// Also the capture index of this sub-expression itself, if group_type
// is CAPTURE.
@@ -497,10 +501,15 @@ class RegExpParser BASE_EMBEDDED {
RegExpBuilder* builder_;
// Stored disjunction type (capture, look-ahead or grouping), if any.
SubexpressionType group_type_;
+ // Stored read direction.
+ RegExpTree::ReadDirection read_direction_;
// Stored disjunction's capture index (if any).
int disjunction_capture_index_;
};
+ // Return the 1-indexed RegExpCapture object, allocate if necessary.
+ RegExpCapture* GetCapture(int index);
+
Isolate* isolate() { return isolate_; }
Zone* zone() const { return zone_; }
@@ -518,6 +527,7 @@ class RegExpParser BASE_EMBEDDED {
FlatStringReader* in_;
uc32 current_;
int next_pos_;
+ int captures_started_;
// The capture count is only valid after we have scanned for captures.
int capture_count_;
bool has_more_;
« no previous file with comments | « src/flag-definitions.h ('k') | src/parser.cc » ('j') | src/regexp/jsregexp.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698