Skip to content

Commit

Permalink
Update to include 'd' flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rbuckton committed Feb 23, 2021
1 parent 8d897d4 commit 48f9a15
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -32016,7 +32016,7 @@ <h1>Runtime Semantics: RegExpInitialize ( _obj_, _pattern_, _flags_ )</h1>
1. Else, let _P_ be ? ToString(_pattern_).
1. If _flags_ is *undefined*, let _F_ be the empty String.
1. Else, let _F_ be ? ToString(_flags_).
1. If _F_ contains any code unit other than `"g"`, `"i"`, `"m"`, `"s"`, `"u"`, or `"y"` or if it contains the same code unit more than once, throw a *SyntaxError* exception.
1. If _F_ contains any code unit other than `"d"`, `"g"`, `"i"`, `"m"`, `"s"`, `"u"`, or `"y"` or if it contains the same code unit more than once, throw a *SyntaxError* exception.
1. If _F_ contains `"u"`, let _BMP_ be *false*; else let _BMP_ be *true*.
1. If _BMP_ is *true*, then
1. Parse _P_ using the grammars in <emu-xref href="#sec-patterns"></emu-xref> and interpreting each of its 16-bit elements as a Unicode BMP code point. UTF-16 decoding is not applied to the elements. The goal symbol for the parse is |Pattern[~U, ~N]|. If the result of parsing contains a |GroupName|, reparse with the goal symbol |Pattern[~U, +N]| and use this result instead. Throw a *SyntaxError* exception if _P_ did not conform to the grammar, if any elements of _P_ were not matched by the parse, or if any Early Error conditions exist.
Expand Down Expand Up @@ -32139,6 +32139,7 @@ <h1>Runtime Semantics: RegExpBuiltinExec ( _R_, _S_ )</h1>
1. Let _flags_ be _R_.[[OriginalFlags]].
1. If _flags_ contains `"g"`, let _global_ be *true*; else let _global_ be *false*.
1. If _flags_ contains `"y"`, let _sticky_ be *true*; else let _sticky_ be *false*.
1. If _flags_ contains `"d"`, let _hasIndices_ be *true*; else let _hasIndices_ be *false*.
1. If _global_ is *false* and _sticky_ is *false*, set _lastIndex_ to 0.
1. Let _matcher_ be _R_.[[RegExpMatcher]].
1. If _flags_ contains `"u"`, let _fullUnicode_ be *true*; else let _fullUnicode_ be *false*.
Expand Down Expand Up @@ -32167,42 +32168,43 @@ <h1>Runtime Semantics: RegExpBuiltinExec ( _R_, _S_ )</h1>
1. Assert: The value of _A_'s `"length"` property is _n_ + 1.
1. Perform ! CreateDataProperty(_A_, `"index"`, _lastIndex_).
1. Perform ! CreateDataProperty(_A_, `"input"`, _S_).
1. Let _indices_ be a new empty List.
1. Let _match_ be the Match Record { [[StartIndex]]: _lastIndex_, [[EndIndex]]: _e_ }.
1. Let _indices_ be a new empty List.
1. Let _groupNames_ be a new empty List.
1. Add _match_ as the last element of _indices_.
1. Let _matchedSubstr_ be ! GetMatchString(_S_, _match_).
1. Perform ! CreateDataProperty(_A_, `"0"`, _matchedSubstr_).
1. If _R_ contains any |GroupName|, then
1. Let _groups_ be ObjectCreate(*null*).
1. Let _groupNames_ be a new empty List.
1. Let _hasGroups_ be *true*.
1. Else,
1. Let _groups_ be *undefined*.
1. Let _groupNames_ be *undefined*.
1. Let _hasGroups_ be *false*.
1. Perform ! CreateDataProperty(_A_, `"groups"`, _groups_).
1. For each integer _i_ such that _i_ &gt; 0 and _i_ &le; _n_, do
1. Let _captureI_ be _i_<sup>th</sup> element of _r_'s _captures_ List.
1. If _captureI_ is *undefined*, then
1. Let _capturedValue_ be *undefined*.
1. Add *undefined* as the last element of _indices_.
1. Append *undefined* to _indices_.
1. Else,
1. Let _captureStart_ be _captureI_'s _startIndex_.
1. Let _captureEnd_ be _captureI_'s _endIndex_.
1. If _fullUnicode_ is *true*, then
1. Set _captureStart_ to ! GetStringIndex(_S_, _Input_, _captureStart_).
1. Set _captureEnd_ to ! GetStringIndex(_S_, _Input_, _captureEnd_).
1. Let _capture_ be the Match Record { [[StartIndex]]: _captureStart_, [[EndIndex]]: _captureEnd_ }.
1. Append _capture_ to _indices_.
1. Let _capturedValue_ be ! GetMatchString(_S_, _capture_).
1. Append _capture_ to _indices_.
1. Perform ! CreateDataProperty(_A_, ! ToString(_i_), _capturedValue_).
1. If the _i_<sup>th</sup> capture of _R_ was defined with a |GroupName|, then
1. Let _s_ be the StringValue of the corresponding |RegExpIdentifierName|.
1. Perform ! CreateDataProperty(_groups_, _s_, _capturedValue_).
1. Assert: _groupNames_ is a List.
1. Append _s_ to _groupNames_.
1. Else,
1. If _groupNames_ is a List, append *undefined* to _groupNames_.
1. Let _indicesArray_ be ! MakeIndicesArray(_S_, _indices_, _groupNames_).
1. Perform ! CreateDataPropertyOrThrow(_A_, `"indices"`, _indicesArray_).
1. Append *undefined* to _groupNames_.
1. If _hasIndices_ is *true*, then
1. Let _indicesArray_ be ! MakeIndicesArray(_S_, _indices_, _groupNames_, _hasGroups_).
1. Perform ! CreateDataPropertyOrThrow(_A_, `"indices"`, _indicesArray_).
1. Return _A_.
</emu-alg>
</emu-clause>
Expand All @@ -32228,7 +32230,8 @@ <h1>GetStringIndex ( _S_, _Input_, _e_ )</h1>
<emu-alg>
1. Assert: Type(_S_) is String.
1. Assert: _Input_ is a List of the code points of _S_ interpreted as a UTF-16 encoded string.
1. Assert: _e_ is an integer value &ge; 0 and &lt; the number of elements in _Input_.
1. Assert: _e_ is an integer value &ge; 0.
1. If _S_ is the empty String, return 0.
1. Let _eUTF_ be the smallest index into _S_ that corresponds to the character at element _e_ of _Input_. If _e_ is greater than or equal to the number of elements in _Input_, then _eUTF_ is the number of code units in _S_.
1. Return _eUTF_.
</emu-alg>
Expand Down Expand Up @@ -32267,7 +32270,7 @@ <h1>GetMatchString ( _S_, _match_ )</h1>
<emu-alg>
1. Assert: Type(_S_) is String.
1. Assert: _match_ is a Match Record.
1. Assert: _match_.[[StartIndex]] is an integer value &ge; 0 and &lt; the length of _S_.
1. Assert: _match_.[[StartIndex]] is an integer value &ge; 0 and &le; the length of _S_.
1. Assert: _match_.[[EndIndex]] is an integer value &ge; _match_.[[StartIndex]] and &le; the length of _S_.
1. Return the portion of _S_ between offset _match_.[[StartIndex]] inclusive and offset _match_.[[EndIndex]] exclusive.
</emu-alg>
Expand All @@ -32286,17 +32289,19 @@ <h1>GetMatchIndicesArray ( _S_, _match_ )</h1>
</emu-clause>

<emu-clause id="sec-makeindicesarray" aoid="MakeIndicesArray">
<h1>MakeIndicesArray ( _S_, _indices_, _groupNames_ )</h1>
<p>The abstract operation MakeIndicesArray with arguments _S_, _indices_, and _groupNames_ performs the following steps:</p>
<h1>MakeIndicesArray ( _S_, _indices_, _groupNames_, _hasGroups_ )</h1>
<p>The abstract operation MakeIndicesArray with arguments _S_, _indices_, _groupNames_, and _hasGroups_ performs the following steps:</p>
<emu-alg>
1. Assert: Type(_S_) is String.
1. Assert: _indices_ is a List.
1. Assert: _groupNames_ is a List or is *undefined*.
1. Assert: Type(_hasGroups_) is Boolean.
1. Let _n_ be the number of elements in _indices_.
1. Assert: _n_ &lt; 2<sup>32</sup> - 1.
1. Assert: _groupNames_ is a List with _n_ - 1 elements.
1. NOTE: The _groupNames_ List contains elements aligned with the _indices_ List starting at _indices_[1].
1. Let _A_ be ! ArrayCreate(_n_).
1. Assert: The value of _A_'s `"length"` property is _n_.
1. If _groupNames_ is not *undefined*, then
1. If _hasGroups_ is *true*, then
1. Let _groups_ be ! ObjectCreate(*null*).
1. Else,
1. Let _groups_ be *undefined*.
Expand All @@ -32308,8 +32313,8 @@ <h1>MakeIndicesArray ( _S_, _indices_, _groupNames_ )</h1>
1. Else,
1. Let _matchIndicesArray_ be *undefined*.
1. Perform ! CreateDataPropertyOrThrow(_A_, ! ToString(_i_), _matchIndicesArray_).
1. If _groupNames_ is not *undefined* and _groupNames_[_i_] is not *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_groups_, _groupNames_[_i_], _matchIndicesArray_).
1. If _i_ &gt; 0 and _groupNames_[_i_ - 1] is not *undefined*, then
1. Perform ! CreateDataPropertyOrThrow(_groups_, _groupNames_[_i_ - 1], _matchIndicesArray_).
1. Return _A_.
</emu-alg>
</emu-clause>
Expand Down Expand Up @@ -32337,6 +32342,8 @@ <h1>get RegExp.prototype.flags</h1>
1. Let _R_ be the *this* value.
1. If Type(_R_) is not Object, throw a *TypeError* exception.
1. Let _result_ be the empty String.
1. Let _hasIndices_ be ! ToBoolean(? Get(_R_, `"hasIndices"`)).
1. If _hasIndices_ is *true*, append the code unit 0x0064 (LATIN SMALL LETTER D) as the last code unit of _result_.
1. Let _global_ be ! ToBoolean(? Get(_R_, `"global"`)).
1. If _global_ is *true*, append the code unit 0x0067 (LATIN SMALL LETTER G) as the last code unit of _result_.
1. Let _ignoreCase_ be ! ToBoolean(? Get(_R_, `"ignoreCase"`)).
Expand Down Expand Up @@ -32368,6 +32375,21 @@ <h1>get RegExp.prototype.global</h1>
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-regexp.prototype.hasIndices">
<h1>get RegExp.prototype.hasIndices</h1>
<p>`RegExp.prototype.hasIndices` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
<emu-alg>
1. Let _R_ be the *this* value.
1. If Type(_R_) is not Object, throw a *TypeError* exception.
1. If _R_ does not have an [[OriginalFlags]] internal slot, then
1. If SameValue(_R_, %RegExp.prototype%) is *true*, return *undefined*.
1. Otherwise, throw a *TypeError* exception.
1. Let _flags_ be _R_.[[OriginalFlags]].
1. If _flags_ contains the code unit 0x0064 (LATIN SMALL LETTER D), return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>

<emu-clause id="sec-get-regexp.prototype.ignorecase">
<h1>get RegExp.prototype.ignoreCase</h1>
<p>`RegExp.prototype.ignoreCase` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:</p>
Expand Down

0 comments on commit 48f9a15

Please sign in to comment.