Skip to content

Commit 4221ff9

Browse files
bakkotljharb
authored andcommitted
use identity escapes where possible
1 parent b07b6cb commit 4221ff9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

spec.emu

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ contributors:
5252
</h1>
5353
<dl class="header">
5454
<dt>description</dt>
55-
<dd>It returns a string representing a |Pattern| for matching _c_. If _c_ is white space or an ASCII punctuator, the returned value is an escape sequence (corresponding with |HexEscapeSequence| if possible, or otherwise with |RegExpUnicodeEscapeSequence|). Otherwise, the returned value is a string representation of _c_ itself.</dd>
55+
<dd>It returns a string representing a |Pattern| for matching _c_. If _c_ is white space or an ASCII punctuator, the returned value is an escape sequence. Otherwise, the returned value is a string representation of _c_ itself.</dd>
5656
</dl>
5757

5858
<emu-alg>
59-
1. Let _punctuators_ be the string-concatenation of *"(){}[]|,.?\*+-^$=<>/#&!%:;@~'`"*, the code unit 0x0022 (QUOTATION MARK), and the code unit 0x005C (REVERSE SOLIDUS).
60-
1. Let _toEscape_ be StringToCodePoints(_punctuators_).
59+
1. If _c_ is matched by |SyntaxCharacter| or _c_ is U+002F (SOLIDUS), then
60+
1. Return the string-concatenation of 0x005C (REVERSE SOLIDUS) and UTF16EncodeCodePoint(_c_).
61+
1. Let _otherPunctuators_ be the string-concatenation of *",-=<>#&!%:;@~'`"* and the code unit 0x0022 (QUOTATION MARK).
62+
1. Let _toEscape_ be StringToCodePoints(_otherPunctuators_).
6163
1. If _toEscape_ contains _c_ or _c_ is matched by |WhiteSpace|, then
6264
1. If _c_ ≤ 0xFF, then
6365
1. Let _hex_ be Number::toString(𝔽(_c_), 16).

0 commit comments

Comments
 (0)