Atom
+ With argument _direction_.
The production Atom :: PatternCharacter evaluates as follows:
1. Let _ch_ be the character matched by |PatternCharacter|.
1. Let _A_ be a one-element CharSet containing the character _ch_.
- 1. Call CharacterSetMatcher(_A_, *false*) and return its Matcher result.
+ 1. Call CharacterSetMatcher(_A_, *false*, _direction_) and return its Matcher result.
The production Atom :: `.` evaluates as follows:
1. Let _A_ be the set of all characters except |LineTerminator|.
- 1. Call CharacterSetMatcher(_A_, *false*) and return its Matcher result.
+ 1. Call CharacterSetMatcher(_A_, *false*, _direction_) and return its Matcher result.
The production Atom :: `\` AtomEscape evaluates as follows:
- 1. Return the Matcher that is the result of evaluating |AtomEscape|.
+ 1. Return the Matcher that is the result of evaluating |AtomEscape| with argument _direction_.
The production Atom :: CharacterClass evaluates as follows:
1. Evaluate |CharacterClass| to obtain a CharSet _A_ and a Boolean _invert_.
- 1. Call CharacterSetMatcher(_A_, _invert_) and return its Matcher result.
+ 1. Call CharacterSetMatcher(_A_, _invert_, _direction_) and return its Matcher result.
The production Atom :: `(` Disjunction `)` evaluates as follows:
- 1. Evaluate |Disjunction| to obtain a Matcher _m_.
+ 1. Evaluate |Disjunction| with argument _direction_ to obtain a Matcher _m_.
1. Let _parenIndex_ be the number of left-capturing parentheses in the entire regular expression that occur to the left of this |Atom|. This is the total number of Atom :: `(` Disjunction `)` Parse Nodes prior to or enclosing this |Atom|.
1. Return an internal Matcher closure that takes two arguments, a State _x_ and a Continuation _c_, and performs the following steps:
1. Let _d_ be an internal Continuation closure that takes one State argument _y_ and performs the following steps:
1. Let _cap_ be a copy of _y_'s _captures_ List.
1. Let _xe_ be _x_'s _endIndex_.
1. Let _ye_ be _y_'s _endIndex_.
- 1. Let _s_ be a new List whose characters are the characters of _Input_ at indices _xe_ (inclusive) through _ye_ (exclusive).
+ 1. If _direction_ is equal +1, then
+ 1. Let _s_ be a fresh List whose characters are the characters of _Input_ at indices _xe_ (inclusive) through _ye_ (exclusive).
+ 1. Else, let _direction_ is equal to -1.
+ 1. Let _s_ be a fresh List whose characters are the characters of _Input_ at indices _ye_ (inclusive) through _xe_ (exclusive).
1. Set _cap_[_parenIndex_+1] to _s_.
1. Let _z_ be the State (_ye_, _cap_).
1. Call _c_(_z_) and return its result.
@@ -30094,25 +30132,27 @@ Atom
The production Atom :: `(` `?` `:` Disjunction `)` evaluates as follows:
- 1. Return the Matcher that is the result of evaluating |Disjunction|.
+ 1. Return the Matcher that is the result of evaluating |Disjunction| with argument _direction_.
- Runtime Semantics: CharacterSetMatcher ( _A_, _invert_ )
- The abstract operation CharacterSetMatcher takes two arguments, a CharSet _A_ and a Boolean flag _invert_, and performs the following steps:
+ Runtime Semantics: CharacterSetMatcher ( _A_, _invert_, _direction_ )
+ The abstract operation CharacterSetMatcher takes three arguments, a CharSet _A_, a Boolean flag _invert_, and an integer _direction_, and performs the following steps:
1. Return an internal Matcher closure that takes two arguments, a State _x_ and a Continuation _c_, and performs the following steps when evaluated:
1. Let _e_ be _x_'s _endIndex_.
- 1. If _e_ is _InputLength_, return ~failure~.
- 1. Let _ch_ be the character _Input_[_e_].
+ 1. Let _f_ be _e_ + _direction_.
+ 1. If _f_ < 0 or _f_ > _InputLength_, return ~failure~.
+ 1. Let _index_ be min(_e_, _f_).
+ 1. Let _ch_ be the character _Input_[_index_].
1. Let _cc_ be Canonicalize(_ch_).
1. If _invert_ is *false*, then
1. If there does not exist a member _a_ of set _A_ such that Canonicalize(_a_) is _cc_, return ~failure~.
1. Else _invert_ is *true*,
1. If there exists a member _a_ of set _A_ such that Canonicalize(_a_) is _cc_, return ~failure~.
1. Let _cap_ be _x_'s _captures_ List.
- 1. Let _y_ be the State (_e_+1, _cap_).
+ 1. Let _y_ be the State (_f_, _cap_).
1. Call _c_(_y_) and return its result.
@@ -30167,6 +30207,7 @@ Runtime Semantics: Canonicalize ( _ch_ )
AtomEscape
+ With argument _direction_.
The production AtomEscape :: DecimalEscape evaluates as follows:
1. Evaluate |DecimalEscape| to obtain an integer _n_.
@@ -30177,9 +30218,10 @@ AtomEscape
1. If _s_ is *undefined*, return _c_(_x_).
1. Let _e_ be _x_'s _endIndex_.
1. Let _len_ be the number of elements in _s_.
- 1. Let _f_ be _e_+_len_.
- 1. If _f_>_InputLength_, return ~failure~.
- 1. If there exists an integer _i_ between 0 (inclusive) and _len_ (exclusive) such that Canonicalize(_s_[_i_]) is not the same character value as Canonicalize(_Input_[_e_+_i_]), return ~failure~.
+ 1. Let _f_ be _e_ + _direction_×_len_.
+ 1. If _f_ < 0 or _f_>_InputLength_, return ~failure~.
+ 1. Let _g_ be min(_e_, _f_).
+ 1. If there exists an integer _i_ between 0 (inclusive) and _len_ (exclusive) such that Canonicalize(_s_[_i_]) is not the same character value as Canonicalize(_Input_[_g_+_i_]), return ~failure~.
1. Let _y_ be the State (_f_, _cap_).
1. Call _c_(_y_) and return its result.
@@ -30187,12 +30229,12 @@ AtomEscape
1. Evaluate |CharacterEscape| to obtain a character _ch_.
1. Let _A_ be a one-element CharSet containing the character _ch_.
- 1. Call CharacterSetMatcher(_A_, *false*) and return its Matcher result.
+ 1. Call CharacterSetMatcher(_A_, *false*, _direction_) and return its Matcher result.
The production AtomEscape :: CharacterClassEscape evaluates as follows:
1. Evaluate |CharacterClassEscape| to obtain a CharSet _A_.
- 1. Call CharacterSetMatcher(_A_, *false*) and return its Matcher result.
+ 1. Call CharacterSetMatcher(_A_, *false*, _direction_) and return its Matcher result.
An escape sequence of the form `\\` followed by a nonzero 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.
@@ -39073,6 +39115,8 @@ Syntax
`\` `B`
[+U] `(` `?` `=` Disjunction[+U] `)`
[+U] `(` `?` `!` Disjunction[+U] `)`
+ `(` `?` `<=` Disjunction[?U] `)`
+ `(` `?` `<!` Disjunction[?U] `)`
[~U] QuantifiableAssertion
QuantifiableAssertion ::