This repository has been archived by the owner on Jan 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
proposal.html
executable file
·600 lines (542 loc) · 25.7 KB
/
proposal.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
<!doctype html>
<meta charset="utf8">
<link rel="stylesheet" href="ecmarkup.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/github.min.css">
<script src="ecmarkup.js"></script>
<pre class=metadata>
title: Template Literal Revision
status: candidate
stage: 4
contributors: Tim Disney
toc: true
</pre>
<emu-intro>
<h1>Introduction</h1>
<p>Template literals should allow the embedding of languages (DSLs etc.). But restrictions on escape sequences make this problematic.</p>
<p>For example, consider making a latex processor with templates:</p>
<pre><code class="javascript">
function latex(strings) {
// ...
}
let document = latex`
\newcommand{\fun}{\textbf{Fun!}} // works just fine
\newcommand{\unicode}{\textbf{Unicode!}} // Illegal token!
\newcommand{\xerxes}{\textbf{King!}} // Illegal token!
Breve over the h goes \u{h}ere // Illegal token!
`
</code></pre>
<p>The problem here is that `\u` is the start of a unicode escape, but ES grammar forces it to be of the form `\u00FF` or `\u{42}`
and considers the token `\unicode` illegal.
Similarly `\x` is the start of a hex escape like `\xFF` but `\xerxes` is illegal. Octal literal escapes have the same problem; `\0100` is illegal.</p>
<h2>Proposal Overview</h2>
<p>Remove the restriction on escape sequences.</p>
<p>Lifting the restriction raises the question of how to handle cooked template values that contain illegal escape sequences. Currently, cooked template values are supposed to replace escape sequences with the "Unicode code point represented by the escape sequence" but this can't happen if the escape sequence is not valid.</p>
<p>The proposed solution is to set the cooked value to `undefined` for template values that contain illegal escape sequences. The raw value is still accessible via `.raw` so embedded DSLs that might contain `undefined` cooked values can just use the raw string:</p>
<pre><code class="javascript">
function tag(strs) {
strs[0] === undefined
strs.raw[0] === "\\unicode and \\u{55}";
}
tag`\unicode and \u{55}`
</code></pre>
<p>This loosening of the escape sequence restriction only applies to tagged template literals; untagged templates still throw an early error for invalid escape sequences:</p>
<pre><code class="javascript">
let bad = `bad escape sequence: \unicode`; // throws early error
</code></pre>
</emu-intro>
<!-- es6num="11.8.6" -->
<emu-clause id="sec-template-literal-lexical-components">
<h1>(<a href="https://tc39.github.io/ecma262/#sec-template-literal-lexical-components">11.8.6</a>) Template Literal Lexical Components</h1>
<h2>Syntax</h2>
<emu-grammar>
Template ::
NoSubstitutionTemplate
TemplateHead
NoSubstitutionTemplate ::
``` TemplateCharacters? ```
TemplateHead ::
``` TemplateCharacters? `${`
TemplateSubstitutionTail ::
TemplateMiddle
TemplateTail
TemplateMiddle ::
`}` TemplateCharacters? `${`
TemplateTail ::
`}` TemplateCharacters? ```
TemplateCharacters ::
TemplateCharacter TemplateCharacters?
</emu-grammar>
<del class="block">
<emu-grammar>
TemplateCharacter ::
`$` [lookahead != `{` ]
`\` EscapeSequence
LineContinuation
LineTerminatorSequence
SourceCharacter but not one of ``` or `\` or `$` or LineTerminator
</emu-grammar>
</del>
<ins class="block">
<emu-grammar>
TemplateCharacter ::
`$` [lookahead != `{` ]
`\` EscapeSequence
`\` NotEscapeSequence
LineContinuation
LineTerminatorSequence
SourceCharacter but not one of ``` or `\` or `$` or LineTerminator
</emu-grammar>
</ins>
<ins class="block">
<emu-grammar>
NotEscapeSequence ::
`0` DecimalDigit
DecimalDigit but not `0`
`x` [lookahead <! HexDigit]
`x` HexDigit [lookahead <! HexDigit]
`u` [lookahead <! HexDigit] [lookahead != `{`]
`u` HexDigit [lookahead <! HexDigit]
`u` HexDigit HexDigit [lookahead <! HexDigit]
`u` HexDigit HexDigit HexDigit [lookahead <! HexDigit]
`u` `{` [lookahead <! HexDigit]
`u` `{` NotCodePoint
`u` `{` CodePoint [lookahead != `}`]
NotCodePoint ::
HexDigits [> but not if MV of HexDigits ≤ 0x10FFFF ]
CodePoint ::
HexDigits [> but not if MV of HexDigits > 0x10FFFF ]
</emu-grammar>
</ins>
<p>A conforming implementation must not use the extended definition of |EscapeSequence| described in <emu-xref href="#sec-additional-syntax-string-literals"></emu-xref> when parsing a |TemplateCharacter|.</p>
<emu-note>
<p>|TemplateSubstitutionTail| is used by the |InputElementTemplateTail| alternative lexical goal.</p>
</emu-note>
</emu-clause>
<!-- es6num="11.8.6.1" -->
<emu-clause id="sec-static-semantics-tv-and-trv">
<h1>(<a href="https://tc39.github.io/ecma262/#sec-static-semantics-tv-and-trv">11.8.6.1</a>) Static Semantics: TV and TRV</h1>
<p>A template literal component is interpreted as a sequence of Unicode code points. The Template Value (TV) of a literal component is described in terms of code unit values (SV, <emu-xref href="#sec-literals-string-literals"></emu-xref>) contributed by the various parts of the template literal component. As part of this process, some Unicode code points within the template component are interpreted as having a mathematical value (MV, <emu-xref href="#sec-literals-numeric-literals"></emu-xref>). In determining a TV, escape sequences are replaced by the UTF-16 code unit(s) of the Unicode code point represented by the escape sequence. The Template Raw Value (TRV) is similar to a Template Value with the difference that in TRVs escape sequences are interpreted literally.</p>
<ul>
<li>
The TV and TRV of <emu-grammar>NoSubstitutionTemplate :: ``` ```</emu-grammar> is the empty code unit sequence.
</li>
<li>
The TV and TRV of <emu-grammar>TemplateHead :: ``` `${`</emu-grammar> is the empty code unit sequence.
</li>
<li>
The TV and TRV of <emu-grammar>TemplateMiddle :: `}` `${`</emu-grammar> is the empty code unit sequence.
</li>
<li>
The TV and TRV of <emu-grammar>TemplateTail :: `}` ```</emu-grammar> is the empty code unit sequence.
</li>
<li>
The TV of <emu-grammar>NoSubstitutionTemplate :: ``` TemplateCharacters ```</emu-grammar> is the TV of |TemplateCharacters|.
</li>
<li>
The TV of <emu-grammar>TemplateHead :: ``` TemplateCharacters `${`</emu-grammar> is the TV of |TemplateCharacters|.
</li>
<li>
The TV of <emu-grammar>TemplateMiddle :: `}` TemplateCharacters `${`</emu-grammar> is the TV of |TemplateCharacters|.
</li>
<li>
The TV of <emu-grammar>TemplateTail :: `}` TemplateCharacters ```</emu-grammar> is the TV of |TemplateCharacters|.
</li>
<li>
The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter</emu-grammar> is the TV of |TemplateCharacter|.
</li>
<del class="block">
<li>
The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is a sequence consisting of the code units in the TV of |TemplateCharacter| followed by all the code units in the TV of |TemplateCharacters| in order.
</li>
</del>
<ins class="block">
<li>
The TV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is:
<ul>
<li>*undefined* if the TV of |TemplateCharacter| is *undefined* or the TV of |TemplateCharacters| is *undefined*, or</li>
<li>a sequence consisting of the code units in the TV of |TemplateCharacter| followed by all the code units in the TV of |TemplateCharacters| in order.</li>
</ul>
</li>
</ins>
<li>
The TV of <emu-grammar>TemplateCharacter :: SourceCharacter but not one of ``` or `\` or `$` or LineTerminator</emu-grammar> is the UTF16Encoding of the code point value of |SourceCharacter|.
</li>
<li>
The TV of <emu-grammar>TemplateCharacter :: `$`</emu-grammar> is the code unit value 0x0024.
</li>
<li>
The TV of <emu-grammar>TemplateCharacter :: `\` EscapeSequence</emu-grammar> is the SV of |EscapeSequence|.
</li>
<ins class="block">
<li>
The TV of <emu-grammar>TemplateCharacter :: `\` NotEscapeSequence</emu-grammar> is *undefined*.
</li>
</ins>
<li>
The TV of <emu-grammar>TemplateCharacter :: LineContinuation</emu-grammar> is the TV of |LineContinuation|.
</li>
<li>
The TV of <emu-grammar>TemplateCharacter :: LineTerminatorSequence</emu-grammar> is the TRV of |LineTerminatorSequence|.
</li>
<li>
The TV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the empty code unit sequence.
</li>
<li>
The TRV of <emu-grammar>NoSubstitutionTemplate :: ``` TemplateCharacters ```</emu-grammar> is the TRV of |TemplateCharacters|.
</li>
<li>
The TRV of <emu-grammar>TemplateHead :: ``` TemplateCharacters `${`</emu-grammar> is the TRV of |TemplateCharacters|.
</li>
<li>
The TRV of <emu-grammar>TemplateMiddle :: `}` TemplateCharacters `${`</emu-grammar> is the TRV of |TemplateCharacters|.
</li>
<li>
The TRV of <emu-grammar>TemplateTail :: `}` TemplateCharacters ```</emu-grammar> is the TRV of |TemplateCharacters|.
</li>
<li>
The TRV of <emu-grammar>TemplateCharacters :: TemplateCharacter</emu-grammar> is the TRV of |TemplateCharacter|.
</li>
<li>
The TRV of <emu-grammar>TemplateCharacters :: TemplateCharacter TemplateCharacters</emu-grammar> is a sequence consisting of the code units in the TRV of |TemplateCharacter| followed by all the code units in the TRV of |TemplateCharacters|, in order.
</li>
<li>
The TRV of <emu-grammar>TemplateCharacter :: SourceCharacter but not one of ``` or `\` or `$` or LineTerminator</emu-grammar> is the UTF16Encoding of the code point value of |SourceCharacter|.
</li>
<li>
The TRV of <emu-grammar>TemplateCharacter :: `$`</emu-grammar> is the code unit value 0x0024.
</li>
<li>
The TRV of <emu-grammar>TemplateCharacter :: `\` EscapeSequence</emu-grammar> is the sequence consisting of the code unit value 0x005C followed by the code units of TRV of |EscapeSequence|.
</li>
<ins class="block">
<li>
The TRV of <emu-grammar>TemplateCharacter :: `\` NotEscapeSequence</emu-grammar> is the sequence consisting of the code unit value 0x005C followed by the code units of TRV of |NotEscapeSequence|.
</li>
</ins>
<li>
The TRV of <emu-grammar>TemplateCharacter :: LineContinuation</emu-grammar> is the TRV of |LineContinuation|.
</li>
<li>
The TRV of <emu-grammar>TemplateCharacter :: LineTerminatorSequence</emu-grammar> is the TRV of |LineTerminatorSequence|.
</li>
<li>
The TRV of <emu-grammar>EscapeSequence :: CharacterEscapeSequence</emu-grammar> is the TRV of the |CharacterEscapeSequence|.
</li>
<li>
The TRV of <emu-grammar>EscapeSequence :: `0`</emu-grammar> is the code unit value 0x0030 (DIGIT ZERO).
</li>
<li>
The TRV of <emu-grammar>EscapeSequence :: HexEscapeSequence</emu-grammar> is the TRV of the |HexEscapeSequence|.
</li>
<li>
The TRV of <emu-grammar>EscapeSequence :: UnicodeEscapeSequence</emu-grammar> is the TRV of the |UnicodeEscapeSequence|.
</li>
<ins class="block">
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `0` DecimalDigit</emu-grammar> is the sequence consisting of the code unit value 0x0030 (DIGIT ZERO) followed by the code units of the TRV of |DecimalDigit|.
</li>
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `x` [lookahead <! HexDigit]</emu-grammar> is the code unit value 0x0078.
</li>
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `x` HexDigit [lookahead <! HexDigit]</emu-grammar> is the sequence consisting of the code unit value 0x0078 followed by the code units of the TRV of |HexDigit|.
</li>
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `u` [lookahead <! { HexDigit, `{` }]</emu-grammar> is the code unit value 0x0075.
</li>
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `u` HexDigit [lookahead <! { HexDigit, `{` }]</emu-grammar> is the sequence consisting of the code unit value 0x0075 followed by the code units of the TRV of |HexDigit|.
</li>
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `u` HexDigit HexDigit [lookahead <! { HexDigit, `{` }]</emu-grammar> is the sequence consisting of the code unit value 0x0075 followed by the code units of the TRV of the first |HexDigit| followed by the code units of the TRV of the second |HexDigit|.
</li>
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `u` HexDigit HexDigit HexDigit [lookahead <! { HexDigit, `{` }]</emu-grammar> is the sequence consisting of the code unit value 0x0075 followed by the code units of the TRV of the first |HexDigit| followed by the code units of the TRV of the second |HexDigit| followed by the code units of the TRV of the third |HexDigit|.
</li>
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `u` `{` [lookahead <! HexDigit]</emu-grammar> is the sequence consisting of the code unit value 0x0075 followed by the code unit value 0x007B.
</li>
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `u` `{` NotCodePoint</emu-grammar> is the sequence consisting of the code unit value 0x0075 followed by the code unit value 0x007B followed by the code units of the TRV of |NotCodePoint|.
</li>
<li>
The TRV of <emu-grammar>NotEscapeSequence :: `u` `{` CodePoint [lookahead <! `}`]</emu-grammar> is the sequence consisting of the code unit value 0x0075 followed by the code unit value 0x007B followed by the code units of the TRV of |CodePoint|.
</li>
<li>
The TRV of <emu-grammar>DecimalDigit :: one of `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`</emu-grammar> is the SV of the |SourceCharacter| that is that single code point.
</li>
<li>
The TRV of <emu-grammar>CodePoint :: HexDigits [> but not if MV of HexDigits > 0x10FFFF ]</emu-grammar> is the sequence consisting of the code units of the TRV of |HexDigits|.
</li>
<li>
The TRV of <emu-grammar>NotCodePoint :: HexDigits [> but not if MV of HexDigits ≤ 0x10FFFF ]</emu-grammar> is the sequence consisting of the code units of the TRV of |HexDigits|.
</li>
</ins>
<li>
The TRV of <emu-grammar>CharacterEscapeSequence :: SingleEscapeCharacter</emu-grammar> is the TRV of the |SingleEscapeCharacter|.
</li>
<li>
The TRV of <emu-grammar>CharacterEscapeSequence :: NonEscapeCharacter</emu-grammar> is the SV of the |NonEscapeCharacter|.
</li>
<li>
The TRV of <emu-grammar>SingleEscapeCharacter :: one of `'` `"` `\` `b` `f` `n` `r` `t` `v`</emu-grammar> is the SV of the |SourceCharacter| that is that single code point.
</li>
<li>
The TRV of <emu-grammar>HexEscapeSequence :: `x` HexDigit HexDigit</emu-grammar> is the sequence consisting of code unit value 0x0078 followed by TRV of the first |HexDigit| followed by the TRV of the second |HexDigit|.
</li>
<li>
The TRV of <emu-grammar>UnicodeEscapeSequence :: `u` Hex4Digits</emu-grammar> is the sequence consisting of code unit value 0x0075 followed by TRV of |Hex4Digits|.
</li>
<li>
The TRV of <emu-grammar>UnicodeEscapeSequence :: `u{` HexDigits `}`</emu-grammar> is the sequence consisting of code unit value 0x0075 followed by code unit value 0x007B followed by TRV of |HexDigits| followed by code unit value 0x007D.
</li>
<li>
The TRV of <emu-grammar>Hex4Digits :: HexDigit HexDigit HexDigit HexDigit</emu-grammar> is the sequence consisting of the TRV of the first |HexDigit| followed by the TRV of the second |HexDigit| followed by the TRV of the third |HexDigit| followed by the TRV of the fourth |HexDigit|.
</li>
<li>
The TRV of <emu-grammar>HexDigits :: HexDigit</emu-grammar> is the TRV of |HexDigit|.
</li>
<li>
The TRV of <emu-grammar>HexDigits :: HexDigits HexDigit</emu-grammar> is the sequence consisting of TRV of |HexDigits| followed by TRV of |HexDigit|.
</li>
<li>
The TRV of a |HexDigit| is the SV of the |SourceCharacter| that is that |HexDigit|.
</li>
<li>
The TRV of <emu-grammar>LineContinuation :: `\` LineTerminatorSequence</emu-grammar> is the sequence consisting of the code unit value 0x005C followed by the code units of TRV of |LineTerminatorSequence|.
</li>
<li>
The TRV of <emu-grammar>LineTerminatorSequence :: <LF></emu-grammar> is the code unit value 0x000A.
</li>
<li>
The TRV of <emu-grammar>LineTerminatorSequence :: <CR></emu-grammar> is the code unit value 0x000A.
</li>
<li>
The TRV of <emu-grammar>LineTerminatorSequence :: <LS></emu-grammar> is the code unit value 0x2028.
</li>
<li>
The TRV of <emu-grammar>LineTerminatorSequence :: <PS></emu-grammar> is the code unit value 0x2029.
</li>
<li>
The TRV of <emu-grammar>LineTerminatorSequence :: <CR><LF></emu-grammar> is the sequence consisting of the code unit value 0x000A.
</li>
</ul>
<emu-note>
<p>TV excludes the code units of |LineContinuation| while TRV includes them. <CR><LF> and <CR> |LineTerminatorSequence|s are normalized to <LF> for both TV and TRV. An explicit |EscapeSequence| is needed to include a <CR> or <CR><LF> sequence.</p>
</emu-note>
</emu-clause>
<!-- es6num="12.2.9" -->
<emu-clause id="sec-template-literals">
<h1>(<a href="https://tc39.github.io/ecma262/#sec-template-literals">12.2.9</a>) Template Literals</h1>
<h2>Syntax</h2>
<del class="block">
<emu-grammar>
TemplateLiteral[Yield] :
NoSubstitutionTemplate
SubstitutionTemplate[?Yield]
SubstitutionTemplate[Yield] :
TemplateHead Expression[In, ?Yield] TemplateSpans[?Yield]
TemplateSpans[Yield] :
TemplateTail
TemplateMiddleList[?Yield] TemplateTail
TemplateMiddleList[Yield] :
TemplateMiddle Expression[In, ?Yield]
TemplateMiddleList[?Yield] TemplateMiddle Expression[In, ?Yield]
</emu-grammar>
</del>
<ins class="block">
<emu-grammar>
TemplateLiteral[Yield, Tagged] :
NoSubstitutionTemplate
SubstitutionTemplate[?Yield, ?Tagged]
SubstitutionTemplate[Yield, Tagged] :
TemplateHead Expression[In, ?Yield] TemplateSpans[?Yield, ?Tagged]
TemplateSpans[Yield, Tagged] :
TemplateTail
TemplateMiddleList[?Yield, ?Tagged] TemplateTail
TemplateMiddleList[Yield, Tagged] :
TemplateMiddle Expression[In, ?Yield]
TemplateMiddleList[?Yield, ?Tagged] TemplateMiddle Expression[In, ?Yield]
</emu-grammar>
</ins>
</emu-clause>
<ins class="block">
<emu-clause id="sec-static-semantics-template-early-errors">
<h1>Static Semantics: Early Errors</h1>
<emu-grammar>
TemplateLiteral[Yield, Tagged] : NoSubstitutionTemplate
</emu-grammar>
<ul>
<li>
It is a Syntax Error if the Tagged parameter was not set and |NoSubstitutionTemplate| Contains |NotEscapeSequence|.
</li>
</ul>
<emu-grammar>
SubstitutionTemplate[Yield, Tagged] : TemplateHead Expression[In, ?Yield] TemplateSpans[?Yield, ?Tagged]
</emu-grammar>
<ul>
<li>
It is a Syntax Error if the Tagged parameter was not set and |TemplateHead| Contains |NotEscapeSequence|.
</li>
</ul>
<emu-grammar>
TemplateSpans[Yield, Tagged] : TemplateTail
</emu-grammar>
<ul>
<li>
It is a Syntax Error if the Tagged parameter was not set and |TemplateTail| Contains |NotEscapeSequence|.
</li>
</ul>
<emu-grammar>
TemplateMiddleList[Yield, Tagged] :
TemplateMiddle Expression[In, ?Yield]
TemplateMiddleList[?Yield, ?Tagged] TemplateMiddle Expression[In, ?Yield]
</emu-grammar>
<ul>
<li>
It is a Syntax Error if the Tagged parameter was not set and |TemplateMiddle| Contains |NotEscapeSequence|.
</li>
</ul>
</emu-clause>
</ins>
<!-- es6num="12.2.9.1" -->
<!-- <emu-clause id="sec-static-semantics-templatestrings">
<h1>(<a href="https://tc39.github.io/ecma262/#sec-static-semantics-templatestrings">12.2.9.1</a>) Static Semantics: TemplateStrings</h1>
<p>With parameter _raw_.</p>
<emu-grammar>TemplateLiteral : NoSubstitutionTemplate</emu-grammar>
<emu-alg>
1. If _raw_ is *false*, then
1. Let _string_ be the TV of |NoSubstitutionTemplate|.
1. Else,
1. Let _string_ be the TRV of |NoSubstitutionTemplate|.
1. Return a List containing the single element, _string_.
</emu-alg>
<emu-grammar>TemplateLiteral : TemplateHead Expression TemplateSpans</emu-grammar>
<emu-alg>
1. If _raw_ is *false*, then
1. Let _head_ be the TV of |TemplateHead|.
1. Else,
1. Let _head_ be the TRV of |TemplateHead|.
1. Let _tail_ be TemplateStrings of |TemplateSpans| with argument _raw_.
1. <del>Return a List containing _head_ followed by the elements, in order, of _tail_.</del>
1. <ins>If _head_ is *undefined* or _tail_ is *undefined*, then</ins>
1. <ins>Return *undefined*.</ins>
1. <ins>Else,</ins>
1. <ins>Return a List containing _head_ followed by the elements, in order, of _tail_.</ins>
</emu-alg>
<emu-grammar>TemplateSpans : TemplateTail</emu-grammar>
<emu-alg>
1. If _raw_ is *false*, then
1. Let _tail_ be the TV of |TemplateTail|.
1. Else,
1. Let _tail_ be the TRV of |TemplateTail|.
1. Return a List containing the single element, _tail_.
</emu-alg>
<emu-grammar>TemplateSpans : TemplateMiddleList TemplateTail</emu-grammar>
<emu-alg>
1. Let _middle_ be TemplateStrings of |TemplateMiddleList| with argument _raw_.
1. If _raw_ is *false*, then
1. Let _tail_ be the TV of |TemplateTail|.
1. Else,
1. Let _tail_ be the TRV of |TemplateTail|.
1. <del>Return a List containing the elements, in order, of _middle_ followed by _tail_.</del>
1. <ins>If _middle_ is *undefined* or _tail_ is *undefined*, then</ins>
1. <ins>Return *undefined*.</ins>
1. <ins>Else,</ins>
1. <ins>Return a List containing the elements, in order, of _middle_ followed by _tail_.</ins>
</emu-alg>
<emu-grammar>TemplateMiddleList : TemplateMiddle Expression</emu-grammar>
<emu-alg>
1. If _raw_ is *false*, then
1. Let _string_ be the TV of |TemplateMiddle|.
1. Else,
1. Let _string_ be the TRV of |TemplateMiddle|.
1. Return a List containing the single element, _string_.
</emu-alg>
<emu-grammar>TemplateMiddleList : TemplateMiddleList TemplateMiddle Expression</emu-grammar>
<emu-alg>
1. Let _front_ be TemplateStrings of |TemplateMiddleList| with argument _raw_.
1. If _raw_ is *false*, then
1. Let _last_ be the TV of |TemplateMiddle|.
1. Else,
1. Let _last_ be the TRV of |TemplateMiddle|.
1. <del>Append _last_ as the last element of the List _front_.</del>
1. <del>Return _front_.</del>
1. <ins>If _last_ is *undefined* or _front_ is *undefined*, then</ins>
1. <ins>Return *undefined*.</ins>
1. <ins>Else,</ins>
1. <ins>Append _last_ as the last element of the List _front_.</ins>
1. <ins>Return _front_.</ins>
</emu-alg>
</emu-clause> -->
<!-- es6num="12.3" -->
<emu-clause id="sec-left-hand-side-expressions">
<h1>(<a href="https://tc39.github.io/ecma262/#sec-left-hand-side-expressions">12.3</a>) Left-Hand-Side Expressions</h1>
<h2>Syntax</h2>
<emu-production name="MemberExpression" params="Yield">
<emu-rhs><emu-nt params="?Yield">PrimaryExpression</emu-nt></emu-rhs>
<emu-rhs>
<emu-nt params="?Yield">MemberExpression</emu-nt>
<emu-t>[</emu-t>
<emu-nt params="In, ?Yield">Expression</emu-nt>
<emu-t>]</emu-t>
</emu-rhs>
<emu-rhs>
<emu-nt params="?Yield">MemberExpression</emu-nt>
<emu-t>.</emu-t>
<emu-nt>IdentifierName</emu-nt>
</emu-rhs>
<del class="block"><emu-rhs>
<emu-nt params="?Yield">MemberExpression</emu-nt>
<emu-nt params="?Yield">TemplateLiteral</emu-nt>
</emu-rhs></del>
<ins class="block"><emu-rhs>
<emu-nt params="?Yield">MemberExpression</emu-nt>
<emu-nt params="?Yield, Tagged">TemplateLiteral</emu-nt>
</emu-rhs></ins>
<emu-rhs>
<emu-nt params="?Yield">SuperProperty</emu-nt>
</emu-rhs>
<emu-rhs>
<emu-nt>MetaProperty</emu-nt>
</emu-rhs>
<emu-rhs>
<emu-t>new</emu-t>
<emu-nt params="?Yield">MemberExpression</emu-nt>
<emu-nt params="?Yield">Arguments</emu-nt>
</emu-rhs>
</emu-production>
<emu-production name="CallExpression" params="Yield">
<emu-rhs>
<emu-nt params="?Yield">MemberExpression</emu-nt>
<emu-nt params="?Yield">Arguments</emu-nt>
</emu-rhs>
<emu-rhs>
<emu-nt params="?Yield">SuperCall</emu-nt>
</emu-rhs>
<emu-rhs>
<emu-nt params="?Yield">CallExpression</emu-nt>
<emu-nt params="?Yield">Arguments</emu-nt>
</emu-rhs>
<emu-rhs>
<emu-nt params="?Yield">CallExpression</emu-nt>
<emu-t>[</emu-t>
<emu-nt params="?Yield">Expression</emu-nt>
<emu-t>]</emu-t>
</emu-rhs>
<emu-rhs>
<emu-nt params="?Yield">CallExpression</emu-nt>
<emu-t>.</emu-t>
<emu-nt>IdentifierName</emu-nt>
</emu-rhs>
<del class="block"><emu-rhs>
<emu-nt params="?Yield">CallExpression</emu-nt>
<emu-nt params="?Yield">TemplateLiteral</emu-nt>
</emu-rhs></del>
<ins class="block"><emu-rhs>
<emu-nt params="?Yield">CallExpression</emu-nt>
<emu-nt params="?Yield, Tagged">TemplateLiteral</emu-nt>
</emu-rhs></ins>
</emu-production>
</emu-grammar>
</emu-clause>