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

Unified Diff: src/regexp/regexp-parser.h

Issue 2050343002: [regexp] Experimental support for regexp named captures (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Proper fixed array cast Created 4 years, 6 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
Index: src/regexp/regexp-parser.h
diff --git a/src/regexp/regexp-parser.h b/src/regexp/regexp-parser.h
index 6142a9ea530fc091ec1eb6aa9e09153950865ac9..31e7d442803700d61e7758e2b6233b867c62452e 100644
--- a/src/regexp/regexp-parser.h
+++ b/src/regexp/regexp-parser.h
@@ -262,6 +262,30 @@ class RegExpParser BASE_EMBEDDED {
// 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(Vector<const uc16> name, int index);
+
+ // Parses the name of a capture group (?<name>pattern). The name must adhere
+ // to IdentifierName in the ECMAScript standard.
+ Vector<const uc16> ParseCaptureGroupName();
+
+ bool ParseNamedBackReference(RegExpBuilder* builder,
+ RegExpParserState* state);
+
+ // Looks up the index of the capture group with the specified name. Returns -1
+ // in case no such group is found.
+ int LookupCaptureGroupIndex(Vector<const uc16> name);
+
+ // 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();
+ void FreeCaptureStrings();
+
Isolate* isolate() { return isolate_; }
Zone* zone() const { return zone_; }
@@ -278,6 +302,9 @@ class RegExpParser BASE_EMBEDDED {
Zone* zone_;
Handle<String>* error_;
ZoneList<RegExpCapture*>* captures_;
+ ZoneList<RegExpCapture*>* named_captures_;
+ ZoneList<RegExpBackReference*>* named_back_references_;
+ ZoneList<Vector<const uc16>> capture_strings_;
FlatStringReader* in_;
uc32 current_;
bool ignore_case_;

Powered by Google App Engine
This is Rietveld 408576698