Skip to content

Commit

Permalink
Unify handling of RegExp CharacterClassEscapes \w and \W and Word Ass…
Browse files Browse the repository at this point in the history
…erts \b and \B (#525)

* Proposed RegExp CharacterClassEscape changes for \w

* Updated per what was agreed at the May 2016 meeting.

Created a new abstract operation "WordCharacters()" that is used by
both IsWordChar() for word assertions and \w/\W CharacterClassEscapes.
  • Loading branch information
msaboff authored and bterlson committed Jun 22, 2016
1 parent 1244a0b commit 996af87
Showing 1 changed file with 31 additions and 248 deletions.
279 changes: 31 additions & 248 deletions spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -27724,16 +27724,14 @@ <h1>Assertion</h1>
</emu-alg>

<!-- es6num="21.2.2.6.1" -->
<emu-clause id="sec-runtime-semantics-iswordchar-abstract-operation" aoid="IsWordChar">
<h1>Runtime Semantics: IsWordChar Abstract Operation</h1>
<p>The abstract operation IsWordChar takes an integer parameter _e_ and performs the following steps:</p>
<emu-clause id="sec-runtime-semantics-wordcharacters-abstract-operation" aoid="WordCharacters">
<h1>Runtime Semantics: WordCharacters Abstract Operation</h1>
<p>The abstract operation WordCharacters performs the following steps:</p>
<emu-alg>
1. If _e_ is -1 or _e_ is _InputLength_, return *false*.
1. Let _c_ be the character _Input_[_e_].
1. If _c_ is one of the sixty-three characters below, return *true*.
<figure>
<table class="lightweight-table">
<tbody>
1. Create a set _A_ of characters containing the sixty-three characters:
<figure>
<table class="lightweight-table">
<tbody>
<tr>
<td>
`a`
Expand Down Expand Up @@ -27959,14 +27957,30 @@ <h1>Runtime Semantics: IsWordChar Abstract Operation</h1>
<td>
</td>
</tr>
</tbody>
</table>
</figure>
1. Return *false*.
</tbody>
</table>
</figure>
1. Create an empty set _U_.
1. For every character _c_ not in set _A_ where Canonicalize(_c_) is in _A_, add _c_ to _U_.
1. Assert: Unless _Unicode_ and _IgnoreCase_ are both true, _U_ is empty.
1. Add the characters in set _U_ to set _A_.
1. Return _A_.
</emu-alg>
</emu-clause>
<!-- es6num="21.2.2.6.2" -->
<emu-clause id="sec-runtime-semantics-iswordchar-abstract-operation" aoid="IsWordChar">
<h1>Runtime Semantics: IsWordChar Abstract Operation</h1>
<p>The abstract operation IsWordChar takes an integer parameter _e_ and performs the following steps:</p>
<emu-alg>
1. If _e_ is -1 or _e_ is _InputLength_, return *false*.
1. Let _c_ be the character _Input_[_e_].
1. Let _WordChars_ be _WordCharacters_().
1. If _c_ is in _WordChars_, return *true*.
1. Return *false*.
</emu-alg>
</emu-clause>
</emu-clause>
</emu-clause>

<!-- es6num="21.2.2.7" -->
<emu-clause id="sec-quantifier">
<h1>Quantifier</h1>
Expand Down Expand Up @@ -28358,240 +28372,9 @@ <h1>CharacterClassEscape</h1>
<p>The production <emu-grammar>CharacterClassEscape :: `d`</emu-grammar> evaluates by returning the ten-element set of characters containing the characters `0` through `9` inclusive.</p>
<p>The production <emu-grammar>CharacterClassEscape :: `D`</emu-grammar> evaluates by returning the set of all characters not included in the set returned by <emu-grammar>CharacterClassEscape :: `d`</emu-grammar>.</p>
<p>The production <emu-grammar>CharacterClassEscape :: `s`</emu-grammar> evaluates by returning the set of characters containing the characters that are on the right-hand side of the |WhiteSpace| or |LineTerminator| productions.</p>
<p>The production <emu-grammar>CharacterClassEscape :: `S`</emu-grammar> evaluates by returning the set of all characters not included in the set returned by <emu-grammar>CharacterClassEscape :: `s`</emu-grammar>.</p>
<p>The production <emu-grammar>CharacterClassEscape :: `w`</emu-grammar> evaluates by returning the set of characters containing the sixty-three characters:</p>
<figure>
<table class="lightweight-table">
<tbody>
<tr>
<td>
`a`
</td>
<td>
`b`
</td>
<td>
`c`
</td>
<td>
`d`
</td>
<td>
`e`
</td>
<td>
`f`
</td>
<td>
`g`
</td>
<td>
`h`
</td>
<td>
`i`
</td>
<td>
`j`
</td>
<td>
`k`
</td>
<td>
`l`
</td>
<td>
`m`
</td>
<td>
`n`
</td>
<td>
`o`
</td>
<td>
`p`
</td>
<td>
`q`
</td>
<td>
`r`
</td>
<td>
`s`
</td>
<td>
`t`
</td>
<td>
`u`
</td>
<td>
`v`
</td>
<td>
`w`
</td>
<td>
`x`
</td>
<td>
`y`
</td>
<td>
`z`
</td>
</tr>
<tr>
<td>
`A`
</td>
<td>
`B`
</td>
<td>
`C`
</td>
<td>
`D`
</td>
<td>
`E`
</td>
<td>
`F`
</td>
<td>
`G`
</td>
<td>
`H`
</td>
<td>
`I`
</td>
<td>
`J`
</td>
<td>
`K`
</td>
<td>
`L`
</td>
<td>
`M`
</td>
<td>
`N`
</td>
<td>
`O`
</td>
<td>
`P`
</td>
<td>
`Q`
</td>
<td>
`R`
</td>
<td>
`S`
</td>
<td>
`T`
</td>
<td>
`U`
</td>
<td>
`V`
</td>
<td>
`W`
</td>
<td>
`X`
</td>
<td>
`Y`
</td>
<td>
`Z`
</td>
</tr>
<tr>
<td>
`0`
</td>
<td>
`1`
</td>
<td>
`2`
</td>
<td>
`3`
</td>
<td>
`4`
</td>
<td>
`5`
</td>
<td>
`6`
</td>
<td>
`7`
</td>
<td>
`8`
</td>
<td>
`9`
</td>
<td>
`_`
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</figure>
<p>The production <emu-grammar>CharacterClassEscape :: `W`</emu-grammar> evaluates by returning the set of all characters not included in the set returned by <emu-grammar>CharacterClassEscape :: `w`</emu-grammar>.</p>
<p>The production <emu-grammar>CharacterClassEscape :: `S`</emu-grammar> evaluates by returning the set of all characters not included in the set returned by <emu-grammar>CharacterClassEscape :: `s`</emu-grammar> .</p>
<p>The production <emu-grammar>CharacterClassEscape :: `w`</emu-grammar> evaluates by returning the set of all characters returned by _WordCharacters_().</p>
<p>The production <emu-grammar>CharacterClassEscape :: `W`</emu-grammar> evaluates by returning the set of all characters not included in the set returned by <emu-grammar>CharacterClassEscape :: `w`</emu-grammar> .</p>
</emu-clause>

<!-- es6num="21.2.2.13" -->
Expand Down

0 comments on commit 996af87

Please sign in to comment.