| Index: src/regexp/regexp-parser.h
|
| diff --git a/src/regexp/regexp-parser.h b/src/regexp/regexp-parser.h
|
| index 6142a9ea530fc091ec1eb6aa9e09153950865ac9..4f2a3e6255cc66274fb261773a252611c9a29f61 100644
|
| --- a/src/regexp/regexp-parser.h
|
| +++ b/src/regexp/regexp-parser.h
|
| @@ -222,13 +222,15 @@ class RegExpParser BASE_EMBEDDED {
|
| RegExpParserState(RegExpParserState* previous_state,
|
| SubexpressionType group_type,
|
| RegExpLookaround::Type lookaround_type,
|
| - int disjunction_capture_index, bool ignore_case,
|
| + int disjunction_capture_index,
|
| + const ZoneVector<uc16>* capture_name, bool ignore_case,
|
| bool unicode, Zone* zone)
|
| : previous_state_(previous_state),
|
| builder_(new (zone) RegExpBuilder(zone, ignore_case, unicode)),
|
| group_type_(group_type),
|
| lookaround_type_(lookaround_type),
|
| - disjunction_capture_index_(disjunction_capture_index) {}
|
| + disjunction_capture_index_(disjunction_capture_index),
|
| + capture_name_(capture_name) {}
|
| // Parser state of containing expression, if any.
|
| RegExpParserState* previous_state() { return previous_state_; }
|
| bool IsSubexpression() { return previous_state_ != NULL; }
|
| @@ -242,9 +244,16 @@ class RegExpParser BASE_EMBEDDED {
|
| // Also the capture index of this sub-expression itself, if group_type
|
| // is CAPTURE.
|
| int capture_index() { return disjunction_capture_index_; }
|
| + // The name of the current sub-expression, if group_type is CAPTURE. Only
|
| + // used for named captures.
|
| + const ZoneVector<uc16>* capture_name() { return capture_name_; }
|
| +
|
| + bool IsNamedCapture() const { return capture_name_ != nullptr; }
|
|
|
| // Check whether the parser is inside a capture group with the given index.
|
| bool IsInsideCaptureGroup(int index);
|
| + // Check whether the parser is inside a capture group with the given name.
|
| + bool IsInsideCaptureGroup(const ZoneVector<uc16>* name);
|
|
|
| private:
|
| // Linked list implementation of stack of states.
|
| @@ -257,11 +266,32 @@ class RegExpParser BASE_EMBEDDED {
|
| RegExpLookaround::Type lookaround_type_;
|
| // Stored disjunction's capture index (if any).
|
| int disjunction_capture_index_;
|
| + // Stored capture name (if any).
|
| + const ZoneVector<uc16>* capture_name_;
|
| };
|
|
|
| // Return the 1-indexed RegExpCapture object, allocate if necessary.
|
| RegExpCapture* GetCapture(int index);
|
|
|
| + // Creates a new named capture at the specified index. Must be called exactly
|
| + // once for each named capture. Fails if a capture with the same name is
|
| + // encountered.
|
| + bool CreateNamedCaptureAtIndex(const ZoneVector<uc16>* name, int index);
|
| +
|
| + // Parses the name of a capture group (?<name>pattern). The name must adhere
|
| + // to IdentifierName in the ECMAScript standard.
|
| + const ZoneVector<uc16>* ParseCaptureGroupName();
|
| +
|
| + bool ParseNamedBackReference(RegExpBuilder* builder,
|
| + RegExpParserState* state);
|
| +
|
| + // After the initial parsing pass, patch corresponding RegExpCapture objects
|
| + // into all RegExpBackReferences. This is done after initial parsing in order
|
| + // to avoid complicating cases in which references comes before the capture.
|
| + void PatchNamedBackReferences();
|
| +
|
| + Handle<FixedArray> CreateCaptureNameMap();
|
| +
|
| Isolate* isolate() { return isolate_; }
|
| Zone* zone() const { return zone_; }
|
|
|
| @@ -278,6 +308,8 @@ class RegExpParser BASE_EMBEDDED {
|
| Zone* zone_;
|
| Handle<String>* error_;
|
| ZoneList<RegExpCapture*>* captures_;
|
| + ZoneList<RegExpCapture*>* named_captures_;
|
| + ZoneList<RegExpBackReference*>* named_back_references_;
|
| FlatStringReader* in_;
|
| uc32 current_;
|
| bool ignore_case_;
|
|
|