From 683300eac06751a29f231932e31182dfd688814f Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Mon, 22 Feb 2021 18:11:24 -0800 Subject: [PATCH] Update to include 'd' flag --- spec.html | 58 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/spec.html b/spec.html index 92c37d064ec..b53cabf2fdd 100644 --- a/spec.html +++ b/spec.html @@ -30845,7 +30845,7 @@

RegExpInitialize ( _obj_, _pattern_, _flags_ )

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 _u_ be *true*; else let _u_ be *false*. 1. If _u_ is *true*, then 1. Let _patternText_ be ! StringToCodePoints(_P_). @@ -30985,6 +30985,7 @@

RegExpBuiltinExec ( _R_, _S_ )

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*. @@ -31013,23 +31014,24 @@

RegExpBuiltinExec ( _R_, _S_ )

1. Assert: The mathematical value of _A_'s *"length"* property is _n_ + 1. 1. Perform ! CreateDataPropertyOrThrow(_A_, *"index"*, 𝔽(_lastIndex_)). 1. Perform ! CreateDataPropertyOrThrow(_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 ! CreateDataPropertyOrThrow(_A_, *"0"*, _matchedSubstr_). 1. If _R_ contains any |GroupName|, then 1. Let _groups_ be ! OrdinaryObjectCreate(*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 ! CreateDataPropertyOrThrow(_A_, *"groups"*, _groups_). 1. For each integer _i_ such that _i_ ≥ 1 and _i_ ≤ _n_, do 1. Let _captureI_ be _i_th 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_. @@ -31037,18 +31039,18 @@

RegExpBuiltinExec ( _R_, _S_ )

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 ! CreateDataPropertyOrThrow(_A_, ! ToString(𝔽(_i_)), _capturedValue_). 1. If the _i_th capture of _R_ was defined with a |GroupName|, then 1. Let _s_ be the CapturingGroupName of the corresponding |RegExpIdentifierName|. 1. Perform ! CreateDataPropertyOrThrow(_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_. @@ -31072,7 +31074,8 @@

GetStringIndex ( _S_, _Input_, _e_ )

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 ≥ 0 and < the number of elements in _Input_. + 1. Assert: _e_ is an integer value ≥ 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_. @@ -31111,7 +31114,7 @@

GetMatchString ( _S_, _match_ )

1. Assert: Type(_S_) is String. 1. Assert: _match_ is a Match Record. - 1. Assert: _match_.[[StartIndex]] is an integer value ≥ 0 and < the length of _S_. + 1. Assert: _match_.[[StartIndex]] is an integer value ≥ 0 and ≤ the length of _S_. 1. Assert: _match_.[[EndIndex]] is an integer value ≥ _match_.[[StartIndex]] and ≤ the length of _S_. 1. Return the portion of _S_ between offset _match_.[[StartIndex]] inclusive and offset _match_.[[EndIndex]] exclusive. @@ -31130,17 +31133,19 @@

GetMatchIndicesArray ( _S_, _match_ )

-

MakeIndicesArray ( _S_, _indices_, _groupNames_ )

-

The abstract operation MakeIndicesArray with arguments _S_, _indices_, and _groupNames_ performs the following steps:

+

MakeIndicesArray ( _S_, _indices_, _groupNames_, _hasGroups_ )

+

The abstract operation MakeIndicesArray with arguments _S_, _indices_, _groupNames_, and _hasGroups_ performs the following steps:

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_ < 232 - 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*. @@ -31152,8 +31157,8 @@

MakeIndicesArray ( _S_, _indices_, _groupNames_ )

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_ > 0 and _groupNames_[_i_ - 1] is not *undefined*, then + 1. Perform ! CreateDataPropertyOrThrow(_groups_, _groupNames_[_i_ - 1], _matchIndicesArray_). 1. Return _A_.
@@ -31181,6 +31186,8 @@

get RegExp.prototype.flags

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"*)). @@ -31212,6 +31219,21 @@

get RegExp.prototype.global

+ +

get RegExp.prototype.hasIndices

+

`RegExp.prototype.hasIndices` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps:

+ + 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*. + +
+

get RegExp.prototype.ignoreCase

`RegExp.prototype.ignoreCase` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps: