Skip to content

Commit d6abf69

Browse files
jmdyckmathiasbynens
authored andcommitted
Editorial: Introduce IdentifierStartChar + IdentifierPartChar (tc39#2392)
Extract `IdentifierStartChar` from `IdentifierStart` and `RegExpIdentifierStart`. Extract `IdentifierPartChar` from `IdentifierPart` and `RegExpIdentifierPart`. This has 3 benefits: - We eliminate some repetition between the productions for Identifiers and RegExpIdentifiers. - We can simplify 4 Early Error rules involving escape sequences, because the constraint can now be expressed in terms of a single nonterminal, rather than a nonterminal plus some terminals. - We can eliminate the Early Error rule for `RegularExpressionFlags` by instead expressing its constraint in the grammar: in the production for `RegularExpressionFlags`, replace `IdentifierPart` with `IdentifierPartChar`. (As a consequence of the last point, this commit undefines the following id: sec-literals-regular-expression-literals-static-semantics-early-errors There didn't seem to be a sensible place to relocate it as an oldid.)
1 parent 7cfde87 commit d6abf69

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

spec.html

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -16175,15 +16175,21 @@ <h2>Syntax</h2>
1617516175
IdentifierName IdentifierPart
1617616176

1617716177
IdentifierStart ::
16178+
IdentifierStartChar
16179+
`\` UnicodeEscapeSequence
16180+
16181+
IdentifierPart ::
16182+
IdentifierPartChar
16183+
`\` UnicodeEscapeSequence
16184+
16185+
IdentifierStartChar ::
1617816186
UnicodeIDStart
1617916187
`$`
1618016188
`_`
16181-
`\` UnicodeEscapeSequence
1618216189

16183-
IdentifierPart ::
16190+
IdentifierPartChar ::
1618416191
UnicodeIDContinue
1618516192
`$`
16186-
`\` UnicodeEscapeSequence
1618716193
&lt;ZWNJ&gt;
1618816194
&lt;ZWJ&gt;
1618916195

@@ -16209,13 +16215,13 @@ <h1>Static Semantics: Early Errors</h1>
1620916215
<emu-grammar>IdentifierStart :: `\` UnicodeEscapeSequence</emu-grammar>
1621016216
<ul>
1621116217
<li>
16212-
It is a Syntax Error if the SV of |UnicodeEscapeSequence| is none of *"$"*, or *"_"*, or ! UTF16EncodeCodePoint(_cp_) for some Unicode code point _cp_ matched by the |UnicodeIDStart| lexical grammar production.
16218+
It is a Syntax Error if the SV of |UnicodeEscapeSequence| is not ! UTF16EncodeCodePoint(_cp_) for some Unicode code point _cp_ matched by the |IdentifierStartChar| lexical grammar production.
1621316219
</li>
1621416220
</ul>
1621516221
<emu-grammar>IdentifierPart :: `\` UnicodeEscapeSequence</emu-grammar>
1621616222
<ul>
1621716223
<li>
16218-
It is a Syntax Error if the SV of |UnicodeEscapeSequence| is none of *"$"*, *"_"*, ! UTF16EncodeCodePoint(&lt;ZWNJ&gt;), ! UTF16EncodeCodePoint(&lt;ZWJ&gt;), or ! UTF16EncodeCodePoint(_cp_) for some Unicode code point _cp_ that would be matched by the |UnicodeIDContinue| lexical grammar production.
16224+
It is a Syntax Error if the SV of |UnicodeEscapeSequence| is not ! UTF16EncodeCodePoint(_cp_) for some Unicode code point _cp_ matched by the |IdentifierPartChar| lexical grammar production.
1621916225
</li>
1622016226
</ul>
1622116227
</emu-clause>
@@ -17057,22 +17063,12 @@ <h2>Syntax</h2>
1705717063

1705817064
RegularExpressionFlags ::
1705917065
[empty]
17060-
RegularExpressionFlags IdentifierPart
17066+
RegularExpressionFlags IdentifierPartChar
1706117067
</emu-grammar>
1706217068
<emu-note>
1706317069
<p>Regular expression literals may not be empty; instead of representing an empty regular expression literal, the code unit sequence `//` starts a single-line comment. To specify an empty regular expression, use: `/(?:)/`.</p>
1706417070
</emu-note>
1706517071

17066-
<emu-clause id="sec-literals-regular-expression-literals-static-semantics-early-errors">
17067-
<h1>Static Semantics: Early Errors</h1>
17068-
<emu-grammar>RegularExpressionFlags :: RegularExpressionFlags IdentifierPart</emu-grammar>
17069-
<ul>
17070-
<li>
17071-
It is a Syntax Error if |IdentifierPart| contains a Unicode escape sequence.
17072-
</li>
17073-
</ul>
17074-
</emu-clause>
17075-
1707617072
<emu-clause id="sec-static-semantics-bodytext" type="sdo">
1707717073
<h1>Static Semantics: BodyText</h1>
1707817074
<dl class="header">
@@ -34244,19 +34240,14 @@ <h2>Syntax</h2>
3424434240
RegExpIdentifierName[?UnicodeMode] RegExpIdentifierPart[?UnicodeMode]
3424534241

3424634242
RegExpIdentifierStart[UnicodeMode] ::
34247-
UnicodeIDStart
34248-
`$`
34249-
`_`
34243+
IdentifierStartChar
3425034244
`\` RegExpUnicodeEscapeSequence[+UnicodeMode]
3425134245
[~UnicodeMode] UnicodeLeadSurrogate UnicodeTrailSurrogate
3425234246

3425334247
RegExpIdentifierPart[UnicodeMode] ::
34254-
UnicodeIDContinue
34255-
`$`
34248+
IdentifierPartChar
3425634249
`\` RegExpUnicodeEscapeSequence[+UnicodeMode]
3425734250
[~UnicodeMode] UnicodeLeadSurrogate UnicodeTrailSurrogate
34258-
&lt;ZWNJ&gt;
34259-
&lt;ZWJ&gt;
3426034251

3426134252
RegExpUnicodeEscapeSequence[UnicodeMode] ::
3426234253
[+UnicodeMode] `u` HexLeadSurrogate `\u` HexTrailSurrogate
@@ -34418,7 +34409,7 @@ <h1>Static Semantics: Early Errors</h1>
3441834409
<emu-grammar>RegExpIdentifierStart :: `\` RegExpUnicodeEscapeSequence</emu-grammar>
3441934410
<ul>
3442034411
<li>
34421-
It is a Syntax Error if the CharacterValue of |RegExpUnicodeEscapeSequence| is not the code point value of *"$"*, *"_"*, or some code point matched by the |UnicodeIDStart| lexical grammar production.
34412+
It is a Syntax Error if the CharacterValue of |RegExpUnicodeEscapeSequence| is not the code point value of some code point matched by the |IdentifierStartChar| lexical grammar production.
3442234413
</li>
3442334414
</ul>
3442434415
<emu-grammar>RegExpIdentifierStart :: UnicodeLeadSurrogate UnicodeTrailSurrogate</emu-grammar>
@@ -34430,7 +34421,7 @@ <h1>Static Semantics: Early Errors</h1>
3443034421
<emu-grammar>RegExpIdentifierPart :: `\` RegExpUnicodeEscapeSequence</emu-grammar>
3443134422
<ul>
3443234423
<li>
34433-
It is a Syntax Error if the CharacterValue of |RegExpUnicodeEscapeSequence| is not the code point value of *"$"*, *"_"*, &lt;ZWNJ&gt;, &lt;ZWJ&gt;, or some code point matched by the |UnicodeIDContinue| lexical grammar production.
34424+
It is a Syntax Error if the CharacterValue of |RegExpUnicodeEscapeSequence| is not the code point value of some code point matched by the |IdentifierPartChar| lexical grammar production.
3443434425
</li>
3443534426
</ul>
3443634427
<emu-grammar>RegExpIdentifierPart :: UnicodeLeadSurrogate UnicodeTrailSurrogate</emu-grammar>
@@ -46022,6 +46013,8 @@ <h1>Lexical Grammar</h1>
4602246013
<emu-prodref name="IdentifierName"></emu-prodref>
4602346014
<emu-prodref name="IdentifierStart"></emu-prodref>
4602446015
<emu-prodref name="IdentifierPart"></emu-prodref>
46016+
<emu-prodref name="IdentifierStartChar"></emu-prodref>
46017+
<emu-prodref name="IdentifierPartChar"></emu-prodref>
4602546018
<emu-prodref name="UnicodeIDStart"></emu-prodref>
4602646019
<emu-prodref name="UnicodeIDContinue"></emu-prodref>
4602746020
<emu-prodref name="ReservedWord"></emu-prodref>

0 commit comments

Comments
 (0)