Skip to content

Commit fda81eb

Browse files
committed
Editorial: Introduce CompilePattern SDO
Take the regexp evaluation rule for Pattern, and re-formulate it as a more conventional SDO.
1 parent 25cf714 commit fda81eb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

spec.html

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34961,9 +34961,13 @@ <h1>Notation</h1>
3496134961
</ul>
3496234962
</emu-clause>
3496334963

34964-
<emu-clause id="sec-pattern">
34965-
<h1>Pattern</h1>
34966-
<p>The production <emu-grammar>Pattern :: Disjunction</emu-grammar> evaluates as follows:</p>
34964+
<emu-clause id="sec-compilepattern" type="sdo" oldids="sec-pattern">
34965+
<h1>Runtime Semantics: CompilePattern</h1>
34966+
<dl class="header">
34967+
<dt>description</dt>
34968+
<dd>It returns an Abstract Closure that takes a String and a non-negative integer, and returns a MatchResult.</dd>
34969+
</dl>
34970+
<emu-grammar>Pattern :: Disjunction</emu-grammar>
3496734971
<emu-alg>
3496834972
1. Let _m_ be CompileSubpattern of |Disjunction| with argument 1.
3496934973
1. Return a new Abstract Closure with parameters (_str_, _index_) that captures _m_ and performs the following steps when called:
@@ -34980,7 +34984,7 @@ <h1>Pattern</h1>
3498034984
1. Return _m_(_x_, _c_).
3498134985
</emu-alg>
3498234986
<emu-note>
34983-
<p>A Pattern evaluates (&ldquo;compiles&rdquo;) to an Abstract Closure value. RegExpBuiltinExec can then apply this procedure to a String and an offset within the String to determine whether the pattern would match starting at exactly that offset within the String, and, if it does match, what the values of the capturing parentheses would be. The algorithms in <emu-xref href="#sec-pattern-semantics"></emu-xref> are designed so that compiling a pattern may throw a *SyntaxError* exception; on the other hand, once the pattern is successfully compiled, applying the resulting Abstract Closure to find a match in a String cannot throw an exception (except for any implementation-defined exceptions that can occur anywhere such as out-of-memory).</p>
34987+
<p>A Pattern compiles to an Abstract Closure value. RegExpBuiltinExec can then apply this procedure to a String and an offset within the String to determine whether the pattern would match starting at exactly that offset within the String, and, if it does match, what the values of the capturing parentheses would be. The algorithms in <emu-xref href="#sec-pattern-semantics"></emu-xref> are designed so that compiling a pattern may throw a *SyntaxError* exception; on the other hand, once the pattern is successfully compiled, applying the resulting Abstract Closure to find a match in a String cannot throw an exception (except for any implementation-defined exceptions that can occur anywhere such as out-of-memory).</p>
3498434988
</emu-note>
3498534989
</emu-clause>
3498634990

@@ -35895,7 +35899,7 @@ <h1>
3589535899
1. Assert: _parseResult_ is a |Pattern| Parse Node.
3589635900
1. Set _obj_.[[OriginalSource]] to _P_.
3589735901
1. Set _obj_.[[OriginalFlags]] to _F_.
35898-
1. Set _obj_.[[RegExpMatcher]] to the Abstract Closure that evaluates _parseResult_ by applying the semantics provided in <emu-xref href="#sec-pattern-semantics"></emu-xref> using _patternCharacters_ as the pattern's List of |SourceCharacter| values and _F_ as the flag parameters.
35902+
1. Set _obj_.[[RegExpMatcher]] to CompilePattern of _parseResult_.
3589935903
1. Perform ? Set(_obj_, *"lastIndex"*, *+0*<sub>𝔽</sub>, *true*).
3590035904
1. Return _obj_.
3590135905
</emu-alg>

0 commit comments

Comments
 (0)