Skip to content

Commit

Permalink
[spec] hex-escape punctuators
Browse files Browse the repository at this point in the history
Fixes 65
  • Loading branch information
ljharb committed Mar 22, 2024
1 parent 44ab978 commit 5325a08
Showing 1 changed file with 13 additions and 22 deletions.
35 changes: 13 additions & 22 deletions spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,6 @@ contributors: Jordan Harband
<emu-clause id="sec-regexp-regular-expression-objects" number="2">
<h1>RegExp (Regular Expression) Objects</h1>

<emu-clause id="sec-patterns" number="1">
<h1>Patterns</h1>

<h2>Syntax</h2>
<p>Each `\\u` |HexTrailSurrogate| for which the choice of associated `u` |HexLeadSurrogate| is ambiguous shall be associated with the nearest possible `u` |HexLeadSurrogate| that would otherwise have no corresponding `\\u` |HexTrailSurrogate|.</p>
<emu-grammar type="definition">
HexNonSurrogate ::
Hex4Digits [> but only if the MV of |Hex4Digits| is not in the inclusive interval from 0xD800 to 0xDFFF]

IdentityEscape[UnicodeMode] ::
[+UnicodeMode] SyntaxCharacter
[+UnicodeMode] `/` <ins>`,` `-` `=` `<` `>` `#` `&` `!` `%` `:` `;` `@` `~` `'` `"` `\``</ins>
<ins>[+UnicodeMode] WhiteSpace</ins>
[~UnicodeMode] SourceCharacter but not UnicodeIDContinue

DecimalEscape ::
NonZeroDigit DecimalDigits[~Sep]? [lookahead &notin; DecimalDigit]
</emu-grammar>
</emu-clause>

<emu-clause id="sec-properties-of-the-regexp-constructor" number="5">
<h1>Properties of the RegExp Constructor</h1>

Expand All @@ -55,9 +35,20 @@ contributors: Jordan Harband
1. Append code unit U+005C (REVERSE SOLIDUS) to _escapedList_.
1. Append code unit U+0078 (LATIN SMALL LETTER X) to _escapedList_.
1. Append code unit U+0033 (DIGIT THREE) to _escapedList_.
1. Append _c_ to _escapedList_.
1. Else if _toEscape_ contains _c_ or _c_ is matched by |WhiteSpace|, then
1. Append code unit U+005C (REVERSE SOLIDUS) to _escapedList_.
1. Append _c_ to _escapedList_.
1. Let _hex_ be Number::toString(𝔽(_c_), *16*<sub>𝔽</sub>).
1. If the length of _hex_ is 1 or 2, then
1. Set _hex_ to StringPad(_hex_, 2, *"0"*, ~start~).
1. Append code unit U+0078 (LATIN SMALL LETTER X) to _escapedList_.
1. Append the code units in _hex_ to _escapedList_.
1. Else,
1. Assert: The length of _hex_ is at most 4.
1. Set _hex_ to StringPad(_hex_, 4, *"0"*, ~start~).
1. Append code unit U+0075 (LATIN SMALL LETTER U) to _escapedList_.
1. Append the code units in _hex_ to _escapedList_.
1. Else,
1. Append _c_ to _escapedList_.
1. Return CodePointsToString(_escapedList_).
</emu-alg>

Expand Down

0 comments on commit 5325a08

Please sign in to comment.