diff --git a/spec.html b/spec.html index a6ab4e6160..1f34ee37e0 100644 --- a/spec.html +++ b/spec.html @@ -35987,7 +35987,7 @@

Static Semantics: Early Errors

It is a Syntax Error if CountLeftCapturingParensWithin(|Pattern|) ≥ 232 - 1.
  • - It is a Syntax Error if |Pattern| contains two or more |GroupSpecifier|s for which the CapturingGroupName of |GroupSpecifier| is the same. + It is a Syntax Error if |Pattern| contains two distinct |GroupSpecifier|s _x_ and _y_ such that the CapturingGroupName of _x_ is the CapturingGroupName of _y_ and such that MightBothParticipate(_x_, _y_) is *true*.
  • QuantifierPrefix :: `{` DecimalDigits `,` DecimalDigits `}` @@ -36133,6 +36133,22 @@

    + +

    + Static Semantics: MightBothParticipate ( + _x_: a Parse Node, + _y_: a Parse Node, + ): a Boolean +

    +
    +
    + + 1. Assert: _x_ and _y_ have the same enclosing |Pattern|. + 1. If the enclosing |Pattern| contains a Disjunction :: Alternative `|` Disjunction Parse Node such that either _x_ is contained within the |Alternative| and _y_ is contained within the derived |Disjunction|, or _x_ is contained within the derived |Disjunction| and _y_ is contained within the |Alternative|, return *false*. + 1. Return *true*. + +
    +

    Static Semantics: CapturingGroupNumber ( ): a positive integer

    @@ -37190,7 +37206,7 @@

    1. Let _n_ be the CapturingGroupNumber of |DecimalEscape|. 1. Assert: _n_ ≤ _rer_.[[CapturingGroupsCount]]. - 1. Return BackreferenceMatcher(_rer_, _n_, _direction_). + 1. Return BackreferenceMatcher(_rer_, « _n_ », _direction_).

    An escape sequence of the form `\\` followed by a non-zero decimal number _n_ matches the result of the _n_th set of capturing parentheses (). It is an error if the regular expression has fewer than _n_ capturing parentheses. If the regular expression has _n_ or more capturing parentheses but the _n_th one is *undefined* because it has not captured anything, then the backreference always succeeds.

    @@ -37226,10 +37242,11 @@

    AtomEscape :: `k` GroupName 1. Let _matchingGroupSpecifiers_ be GroupSpecifiersThatMatch(|GroupName|). - 1. Assert: _matchingGroupSpecifiers_ contains a single |GroupSpecifier|. - 1. Let _groupSpecifier_ be the sole element of _matchingGroupSpecifiers_. - 1. Let _parenIndex_ be CountLeftCapturingParensBefore(_groupSpecifier_). - 1. Return BackreferenceMatcher(_rer_, _parenIndex_, _direction_). + 1. Let _parenIndices_ be a new empty List. + 1. For each |GroupSpecifier| _groupSpecifier_ of _matchingGroupSpecifiers_, do + 1. Let _parenIndex_ be CountLeftCapturingParensBefore(_groupSpecifier_). + 1. Append _parenIndex_ to _parenIndices_. + 1. Return BackreferenceMatcher(_rer_, _parenIndices_, _direction_). @@ -37272,20 +37289,23 @@

    BackreferenceMatcher ( _rer_: a RegExp Record, - _n_: a positive integer, + _ns_: a List of positive integers, _direction_: ~forward~ or ~backward~, ): a Matcher

    - 1. Assert: _n_ ≥ 1. - 1. Return a new Matcher with parameters (_x_, _c_) that captures _rer_, _n_, and _direction_ and performs the following steps when called: + 1. Return a new Matcher with parameters (_x_, _c_) that captures _rer_, _ns_, and _direction_ and performs the following steps when called: 1. Assert: _x_ is a MatchState. 1. Assert: _c_ is a MatcherContinuation. 1. Let _Input_ be _x_.[[Input]]. 1. Let _cap_ be _x_.[[Captures]]. - 1. Let _r_ be _cap_[_n_]. + 1. Let _r_ be *undefined*. + 1. For each integer _n_ of _ns_, do + 1. If _cap_[_n_] is not *undefined*, then + 1. Assert: _r_ is *undefined*. + 1. Set _r_ to _cap_[_n_]. 1. If _r_ is *undefined*, return _c_(_x_). 1. Let _e_ be _x_.[[EndIndex]]. 1. Let _rs_ be _r_.[[StartIndex]]. @@ -38524,6 +38544,7 @@

    1. Let _groups_ be *undefined*. 1. Let _hasGroups_ be *false*. 1. Perform ! CreateDataPropertyOrThrow(_A_, *"groups"*, _groups_). + 1. Let _matchedGroupNames_ be a new empty List. 1. For each integer _i_ such that 1 ≤ _i_ ≤ _n_, in ascending order, do 1. Let _captureI_ be _i_th element of _r_.[[Captures]]. 1. If _captureI_ is *undefined*, then @@ -38541,8 +38562,14 @@

    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 that |GroupName|. - 1. Perform ! CreateDataPropertyOrThrow(_groups_, _s_, _capturedValue_). - 1. Append _s_ to _groupNames_. + 1. If _matchedGroupNames_ contains _s_, then + 1. Assert: _capturedValue_ is *undefined*. + 1. Append *undefined* to _groupNames_. + 1. Else, + 1. If _capturedValue_ is not *undefined*, append _s_ to _matchedGroupNames_. + 1. NOTE: If there are multiple groups named _s_, _groups_ may already have an _s_ property at this point. However, because _groups_ is an ordinary object whose properties are all writable data properties, the call to CreateDataPropertyOrThrow is nevertheless guaranteed to succeed. + 1. Perform ! CreateDataPropertyOrThrow(_groups_, _s_, _capturedValue_). + 1. Append _s_ to _groupNames_. 1. Else, 1. Append *undefined* to _groupNames_. 1. If _hasIndices_ is *true*, then @@ -38685,7 +38712,9 @@

    1. Perform ! CreateDataPropertyOrThrow(_A_, ! ToString(𝔽(_i_)), _matchIndexPair_). 1. If _i_ > 0 and _groupNames_[_i_ - 1] is not *undefined*, then 1. Assert: _groups_ is not *undefined*. - 1. Perform ! CreateDataPropertyOrThrow(_groups_, _groupNames_[_i_ - 1], _matchIndexPair_). + 1. Let _s_ be _groupNames_[_i_ - 1]. + 1. NOTE: If there are multiple groups named _s_, _groups_ may already have an _s_ property at this point. However, because _groups_ is an ordinary object whose properties are all writable data properties, the call to CreateDataPropertyOrThrow is nevertheless guaranteed to succeed. + 1. Perform ! CreateDataPropertyOrThrow(_groups_, _s_, _matchIndexPair_). 1. Return _A_.