-
Notifications
You must be signed in to change notification settings - Fork 68
/
x7.html
2348 lines (2344 loc) · 77.1 KB
/
x7.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
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html class="split chapter"><head><meta charset="utf-8"><title>7 Lexical Conventions # Ⓣ Ⓔ ① Ⓐ — Annotated ES5</title><link rel="stylesheet" href="style.css"><link href="x6.html" title="6 Source Text " rel="prev">
<link href="spec.html" title="TOC" rel="index">
<link href="x8.html" title="8 Types " rel="next">
</head><body><div class="head">
<h2 id="top">Annotated ECMAScript 5.1 <span id="timestamp"></span></h2>
<div id="mascot-treehouse">
<img id="mascot" align="left" src="js-mascot.svg" alt=""><img id="bubble" src="bubble.svg" alt=""></div>
<p id="slogan">‟Ex igne vita”</p>
<div id="annotations"></div>
<script src="timestamp.js"></script></div>
<nav>
<a href="x6.html">← 6 Source Text </a> –
<a href="spec.html" class="toc-nav">TOC</a> –
<a href="x8.html">8 Types →</a>
<ol class="toc"><li><a href="x7.html#x7" id="x7-toc">7 Lexical Conventions</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x7.html#x7.1" id="x7.1-toc">7.1 Unicode Format-Control Characters</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.2" id="x7.2-toc">7.2 White Space</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.3" id="x7.3-toc">7.3 Line Terminators</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.4" id="x7.4-toc">7.4 Comments</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.5" id="x7.5-toc">7.5 Tokens</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.6" id="x7.6-toc">7.6 Identifier Names and Identifiers</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x7.html#x7.6.1" id="x7.6.1-toc">7.6.1 Reserved Words</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x7.html#x7.6.1.1" id="x7.6.1.1-toc">7.6.1.1 Keywords</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.6.1.2" id="x7.6.1.2-toc">7.6.1.2 Future Reserved Words</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li></ol></li><li><a href="x7.html#x7.7" id="x7.7-toc">7.7 Punctuators</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.8" id="x7.8-toc">7.8 Literals</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x7.html#x7.8.1" id="x7.8.1-toc">7.8.1 Null Literals</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.8.2" id="x7.8.2-toc">7.8.2 Boolean Literals</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.8.3" id="x7.8.3-toc">7.8.3 Numeric Literals</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.8.4" id="x7.8.4-toc">7.8.4 String Literals</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.8.5" id="x7.8.5-toc">7.8.5 Regular Expression Literals</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li><li><a href="x7.html#x7.9" id="x7.9-toc">7.9 Automatic Semicolon Insertion</a>
<b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> <ol><li><a href="x7.html#x7.9.1" id="x7.9.1-toc">7.9.1 Rules of Automatic Semicolon Insertion</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li><li><a href="x7.html#x7.9.2" id="x7.9.2-toc">7.9.2 Examples of Automatic Semicolon Insertion</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b> </li></ol></li></ol></li></ol></nav>
<h2 id="x7">7 Lexical Conventions <a href="#x7">#</a> <a href="#x7-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h2>
<p>
The
source text of an ECMAScript program is first converted into a
sequence of input elements, which are tokens, line terminators,
comments, or white space. The source text is scanned from left to
right, repeatedly taking the longest possible sequence of characters
as the next input element.</p>
<p>
There
are two goal symbols for the lexical grammar. The <i>InputElementDiv</i>
symbol is used in those syntactic grammar contexts where a leading
division (<code><b>/</b></code>) or
division-assignment (<code><b>/=</b></code>)
operator is permitted. The <i>InputElementRegExp</i>
symbol is used in other syntactic grammar contexts.</p>
<p><b class="note">NOTE</b> There
are no syntactic grammar contexts where both a leading division or
division-assignment, and a leading <i><a href="#x7.8.5">RegularExpressionLiteral</a></i>
are permitted. This is not affected by semicolon insertion (see
<a href="#x7.9">7.9</a>); in examples such as the following:</p>
<p class="code-example">
<code><b>a
= b<br>/hi/g.exec(c).map(d);</b></code></p>
<p class="sm-btm">
where
the first non-whitespace, non-comment
character after a <i>LineTerminator</i>
is slash
(<code><b>/</b></code>)
and the syntactic context allows division
or division-assignment, no semicolon is inserted at the
<i>LineTerminator</i>.
That is, the above example is interpreted in the same way as:</p>
<p class="code-example">
<code><b>a
= b / hi / g.</b></code><code><b>exec</b></code><code><b>(c).map(d);</b></code></p>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>InputElementDiv </i><b>::</b></p>
<p class="def1-btm">
<i>WhiteSpace<br>LineTerminator<br>Comment<br>Token<br>DivPunctuator<br></i>
</p>
<p class="keep">
<i>InputElementRegExp </i><b>::</b></p>
<p class="def1-btm">
<i>WhiteSpace<br>LineTerminator<br>Comment<br>Token<br>RegularExpressionLiteral</i></p>
<h3 id="x7.1">7.1 Unicode Format-Control Characters <a href="#x7.1">#</a> <a href="#x7.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
The
Unicode format-control characters (i.e., the characters in category
“Cf” in the Unicode Character Database such as <span class="small-caps">left-to-right
mark</span> or <span class="small-caps">right-to-left
mark</span>) are control codes used to control the formatting of a
range of text in the absence of higher-level protocols for this
(such as mark-up languages).</p>
<p>
It is
useful to allow format-control characters in source text to
facilitate editing and display. All format control characters may be
used within comments, and within string literals and regular
expression literals.</p>
<p>
<ZWNJ>
and <ZWJ> are
format-control characters that are used to make necessary
distinctions when forming words or phrases in certain languages. In
ECMAScript source text, <ZWNJ>
and <ZWJ>
may also be used in an identifier after the first character.
</p>
<p>
<BOM>
is a format-control character used primarily at the start of a text
to mark it as Unicode and to allow detection of the text's encoding
and byte order. <BOM>
characters intended for this purpose can sometimes also appear after
the start of a text, for example as a result of concatenating files.
<BOM> characters are treated as white space characters (see
<a href="#x7.2">7.2</a>).
</p>
<p class="sm-btm">
The
special treatment of certain format-control characters outside of
comments, string literals, and regular expression literals is
summarized in Table 1.</p>
<center>
<table width="690" border="1" bordercolor="#000000" cellpadding="22" cellspacing="0" rules="GROUPS"><caption>Table 1 — Format-Control Character Usage</caption>
<colgroup><col width="130"><col width="159"><col width="120"><col width="103"></colgroup><tbody><tr valign="TOP"><td width="130" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Code
Unit Value</span></b></i></p>
</td>
<td width="159" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Name</span></b></i></p>
</td>
<td width="120" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Formal
Name</span></b></i></p>
</td>
<td width="103" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Usage</span></b></i></p>
</td>
</tr></tbody><tbody><tr valign="TOP"><td width="130">
<p>
<code><b>\u200C</b></code></p>
</td>
<td width="159">
<p>
Zero
width non-joiner</p>
</td>
<td width="120">
<p>
<ZWNJ></p>
</td>
<td width="103">
<p>
<i>IdentifierPart</i></p>
</td>
</tr><tr valign="TOP"><td width="130">
<p>
<code><b>\u200D</b></code></p>
</td>
<td width="159">
<p>
Zero
width joiner</p>
</td>
<td width="120">
<p>
<ZWJ></p>
</td>
<td width="103">
<p>
<i>IdentifierPart</i></p>
</td>
</tr><tr valign="TOP"><td width="130">
<p>
<code><b>\uFEFF</b></code></p>
</td>
<td width="159">
<p>
Byte
Order Mark</p>
</td>
<td width="120">
<p>
<BOM></p>
</td>
<td width="103">
<p>
<i>Whitespace</i></p>
</td>
</tr></tbody></table></center>
<h3 id="x7.2">7.2 White Space <a href="#x7.2">#</a> <a href="#x7.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
White
space characters are used to improve source text readability and to
separate tokens (indivisible lexical units) from each other, but are
otherwise insignificant. White space characters may occur between
any two tokens and at the start or end of input. White space
characters may also occur within a <i><a href="#x7.8.4">StringLiteral</a></i>
or a <i><a href="#x7.8.5">RegularExpressionLiteral</a></i>
(where they are considered significant characters forming part of
the literal value) or within a <i>Comment</i>,
but cannot appear within any other kind of token.</p>
<p class="sm-btm">
The
ECMAScript white space characters are listed in Table 2.</p>
<center>
<table id="WhiteSpace" width="528" border="1" bordercolor="#000000" cellpadding="22" cellspacing="0" rules="GROUPS"><caption>Table 2 — Whitespace Characters</caption>
<colgroup><col width="141"><col width="143"><col width="110"></colgroup><tbody><tr valign="TOP"><td width="141" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Code
Unit Value</span></b></i></p>
</td>
<td width="143" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Name</span></b></i></p>
</td>
<td width="110" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Formal
Name</span></b></i></p>
</td>
</tr></tbody><tbody><tr valign="TOP"><td width="141">
<p>
<code><b>\u0009</b></code></p>
</td>
<td width="143">
<p>
Tab</p>
</td>
<td width="110">
<p>
<TAB></p>
</td>
</tr><tr valign="TOP"><td width="141">
<p>
<code><b>\u000B</b></code></p>
</td>
<td width="143">
<p>
Vertical
Tab</p>
</td>
<td width="110">
<p>
<VT></p>
</td>
</tr><tr valign="TOP"><td width="141">
<p>
<code><b>\u000C</b></code></p>
</td>
<td width="143">
<p>
Form
Feed</p>
</td>
<td width="110">
<p>
<FF></p>
</td>
</tr><tr valign="TOP"><td width="141">
<p>
<code><b>\u0020</b></code></p>
</td>
<td width="143">
<p>
Space</p>
</td>
<td width="110">
<p>
<SP></p>
</td>
</tr><tr valign="TOP"><td width="141">
<p>
<code><b>\u00A0</b></code></p>
</td>
<td width="143">
<p>
No-break
space</p>
</td>
<td width="110">
<p>
<#x0a></p>
</td>
</tr><tr valign="TOP"><td width="141">
<p>
<code><b>\uFEFF</b></code></p>
<p>
Other
category “Zs”</p>
</td>
<td width="143">
<p>
Byte
Order Mark</p>
<p>
Any
other Unicode “space separator”</p>
</td>
<td width="110">
<p>
<BOM></p>
<p>
<USP></p>
</td>
</tr></tbody></table></center>
<p>
ECMAScript
implementations must recognize all of the white space characters
defined in Unicode 3.0. Later editions of the Unicode Standard may
define other white space characters. ECMAScript implementations may
recognize white space characters from later editions of the Unicode
Standard.</p>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>WhiteSpace<b>
</b></i><b>::</b></p>
<p class="def1-btm">
<TAB><br><VT><br><FF><br><SP><br><#x0a><br><BOM><br><USP></p>
<h3 id="x7.3">7.3 Line Terminators <a href="#x7.3">#</a> <a href="#x7.3-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
Like
white space characters, line terminator characters are used to
improve source text readability and to separate tokens (indivisible
lexical units) from each other. However, unlike white space
characters, line terminators have some influence over the behaviour
of the syntactic grammar. In general, line terminators may occur
between any two tokens, but there are a few places where they are
forbidden by the syntactic grammar. Line terminators also affect the
process of automatic semicolon insertion (<a href="#x7.9">7.9</a>). A line terminator
cannot occur within any token except a <i><a href="#x7.8.4">StringLiteral</a></i>.
Line terminators may only occur within a <i><a href="#x7.8.4">StringLiteral</a></i>
token as part of a <i>LineContinuation</i>.
</p>
<p>
A
line terminator can occur within a <i>MultiLineComment</i>
(<a href="#x7.4">7.4</a>) but cannot occur within a <i>SingleLineComment</i>.
</p>
<p>
Line
terminators are included in the set of white space characters that
are matched by the <code><b>\s</b></code>
class in regular expressions.</p>
<p class="sm-btm">
The
ECMAScript line terminator characters are listed in Table 3.</p>
<center>
<table id="LineTerminator" width="566" border="1" bordercolor="#000000" cellpadding="22" cellspacing="0" rules="NONE"><caption>Table 3 — Line Terminator Characters</caption>
<colgroup><col width="133"><col width="152"><col width="147"></colgroup><tbody><tr valign="TOP"><td width="133" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Code
Unit Value</span></b></i></p>
</td>
<td width="152" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Name</span></b></i></p>
</td>
<td width="147" bgcolor="#c0c0c0">
<p>
<i><b><span class="table-header">Formal
Name</span></b></i></p>
</td>
</tr><tr valign="TOP"><td width="133">
<p>
<code><b>\u000A</b></code></p>
</td>
<td width="152">
<p>
Line
Feed</p>
</td>
<td width="147">
<p>
<LF></p>
</td>
</tr><tr valign="TOP"><td width="133">
<p>
<code><b>\u000D</b></code></p>
</td>
<td width="152">
<p>
Carriage
Return
</p>
</td>
<td width="147">
<p>
<CR></p>
</td>
</tr><tr valign="TOP"><td width="133">
<p>
<code><b>\u2028</b></code></p>
</td>
<td width="152">
<p>
Line
separator</p>
</td>
<td width="147">
<p>
<LS></p>
</td>
</tr><tr valign="TOP"><td width="133">
<p>
<code><b>\u2029</b></code></p>
</td>
<td width="152">
<p>
Paragraph
separator</p>
</td>
<td width="147">
<p>
<PS></p>
</td>
</tr></tbody></table></center>
<p>
Only
the characters in Table 3 are treated as line terminators. Other new
line or line breaking characters are treated as white space but not
as line terminators. The character sequence <CR><LF> is
commonly used as a line terminator. It should be considered a single
character for the purpose of reporting line numbers.</p>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>LineTerminator </i><b>::</b></p>
<p class="def1-btm">
<LF><br><CR><br><LS><br><PS></p>
<p class="keep">
<i>LineTerminatorSequence </i><b>::</b></p>
<p class="def1-btm">
<LF><br><CR>
[<a href="x5.html#lookahead-not-in">lookahead
<span class="symbol">∉</span></a>
<LF>
]<br><LS><br><PS><br><CR>
<LF></p>
<h3 id="x7.4">7.4 Comments <a href="#x7.4">#</a> <a href="#x7.4-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
Comments
can be either single or multi-line. Multi-line comments cannot nest.</p>
<p>
Because
a single-line comment can contain any character except a
<i>LineTerminator</i>
character, and because of the general rule that a token is always as
long as possible, a single-line comment always consists of all
characters from the <code><b>//</b></code>
marker to the end of the line. However, the <i>LineTerminator</i>
at the end of the line is not considered to be part of the
single-line comment; it is recognised separately by the lexical
grammar and becomes part of the stream of input elements for the
syntactic grammar. This point is very important, because it implies
that the presence or absence of single-line comments does not affect
the process of automatic semicolon insertion (see <a href="#x7.9">7.9</a>).</p>
<p>
Comments
behave like white space and are discarded except that, if a
<i>MultiLineComment</i>
contains a line terminator character, then the entire comment is
considered to be a <i>LineTerminator</i>
for purposes of parsing by the syntactic grammar.</p>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>Comment </i><b>::</b></p>
<p class="def1-btm">
<i>MultiLineComment<br>SingleLineComment</i></p>
<p class="keep">
<i>MultiLineComment </i><b>::</b></p>
<p class="def1-btm">
<code><b>/*</b></code> <i>MultiLineCommentChars</i><sub>opt</sub><code><b>*/</b></code></p>
<p class="keep">
<i>MultiLineCommentChars </i><b>::</b></p>
<p class="def1-btm">
<i>MultiLineNotAsteriskChar
MultiLineCommentChars</i><sub>opt</sub><i><br></i><code><b>*</b></code> <i>PostAsteriskCommentChars</i><sub>opt</sub></p>
<p class="keep">
<i>PostAsteriskCommentChars </i><b>::</b></p>
<p class="def1-btm">
<i>MultiLineNotForwardSlashOrAsteriskChar
MultiLineCommentChars</i><sub>opt</sub><i><br></i><code><b>*</b></code> <i>PostAsteriskCommentChars</i><sub>opt</sub></p>
<p class="keep">
<i>MultiLineNotAsteriskChar<b>
</b></i><b>::</b></p>
<p class="def1-btm">
<i>SourceCharacter </i><b>but
not</b><i> asterisk </i><code><b>*</b></code></p>
<p class="keep">
<i>MultiLineNotForwardSlashOrAsteriskChar </i><b>::</b></p>
<p class="def1-btm">
<i>SourceCharacter<b>
</b></i><b>but
not</b><i> forward-slash </i><code><b>/</b></code> <i><b>
</b></i><b>or</b><i>asterisk </i><code><b>*</b></code></p>
<p class="keep">
<i>SingleLineComment </i><b>::</b></p>
<p class="def1-btm">
<code><b>//</b></code> <i>SingleLineCommentChars</i><sub>opt</sub></p>
<p class="keep">
<i>SingleLineCommentChars </i><b>::</b></p>
<p class="def1-btm">
<i>SingleLineCommentChar
SingleLineCommentChars</i><sub>opt</sub></p>
<p class="keep">
<i>SingleLineCommentChar </i><b>::</b></p>
<p class="def1-btm">
<i>SourceCharacter<b>
</b></i><b>but
not</b><i> LineTerminator</i></p>
<h3 id="x7.5">7.5 Tokens <a href="#x7.5">#</a> <a href="#x7.5-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>Token </i><b>::</b></p>
<p class="def1-btm">
<i>IdentifierName<br>Punctuator<br>NumericLiteral<br>StringLiteral</i></p>
<p class="sp">
</p><p><b class="note">NOTE</b> The
<i>DivPunctuator</i> and
<i><a href="#x7.8.5">RegularExpressionLiteral</a></i>
productions define tokens, but are not included in the <i>Token</i>
production.</p>
<h3 id="x7.6">7.6 Identifier Names and Identifiers <a href="#x7.6">#</a> <a href="#x7.6-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p>
Identifier
Names are tokens that are interpreted according to the grammar given
in the “Identifiers” section of chapter 5 of the Unicode
standard, with some small modifications. An <i>Identifier</i>
is an <i>IdentifierName</i>
that is not a <i>ReservedWord</i>
(see <a href="#x7.6.1">7.6.1</a>). The Unicode identifier grammar is based on both
normative and informative character categories specified by the
Unicode Standard. The characters in the specified categories in
version 3.0 of the Unicode standard must be treated as in those
categories by all conforming ECMAScript implementations.</p>
<p>
This
standard specifies specific character additions: The dollar sign (<code><b>$</b></code>)
and the underscore (<code><b>_</b></code>)
are permitted anywhere in an <i>IdentifierName</i>.</p>
<p>
Unicode
escape sequences are also permitted in an <i>IdentifierName</i>,
where they contribute a single character to the <i>IdentifierName</i>,
as computed by the CV of the <i>UnicodeEscapeSequence</i>
(see <a href="#x7.8.4">7.8.4</a>). The <code><b>\</b></code>
preceding the <i>UnicodeEscapeSequence</i>
does not contribute a character to the <i>IdentifierName</i>.
A <i>UnicodeEscapeSequence</i>
cannot be used to put a character into an <i>IdentifierName </i>that would otherwise be illegal. In other words, if a <code><b>\
</b></code> <i>UnicodeEscapeSequence</i>
sequence were replaced by its <i>UnicodeEscapeSequence</i>'s
CV, the result must still be a valid <i>IdentifierName </i>that has the exact same sequence of characters as the
original <i>IdentifierName</i>.
All interpretations of identifiers within this specification are
based upon their actual characters regardless of whether or not an
escape sequence was used to contribute any particular characters.</p>
<p>
Two
<i>IdentifierName </i>that
are canonically equivalent according to the Unicode standard are <i>not</i>
equal unless they are represented by the exact same sequence of code
units (in other words, conforming ECMAScript implementations are
only required to do bitwise comparison on IdentifierName values).
The intent is that the incoming source text has been converted to
normalised form C before it reaches the compiler.</p>
<p>
ECMAScript
implementations may recognize identifier characters defined in later
editions of the Unicode Standard. If portability is a concern,
programmers should only employ identifier characters defined in
Unicode 3.0.</p>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>Identifier </i><b>::</b></p>
<p class="def1-btm">
<i>IdentifierName </i><b>but
not</b><i> ReservedWord</i></p>
<p class="keep">
<i>IdentifierName<b>
</b></i><b>::</b></p>
<p class="def1-btm">
<i>IdentifierStart<br>IdentifierName
IdentifierPart</i></p>
<p class="keep">
<i>IdentifierStart </i><b>::</b></p>
<p class="def1-btm">
<i>UnicodeLetter<br></i><code><b>$<br>_</b></code> <i><br></i><code><b>\
</b></code> <i>UnicodeEscapeSequence</i></p>
<p class="keep">
<i>IdentifierPart </i><b>::</b></p>
<p class="def1-btm">
<i>IdentifierStart<br>UnicodeCombiningMark<br>UnicodeDigit<br>UnicodeConnectorPunctuation<br></i><ZWNJ><br><ZWJ></p>
<p class="keep">
<i>UnicodeLetter</i></p>
<p class="def1-btm">
any
character in the Unicode categories “Uppercase letter (Lu)”,
“Lowercase letter (Ll)”, “Titlecase letter (Lt)”, “Modifier
letter (Lm)”, “Other letter (Lo)”, or “Letter number (Nl)”.</p>
<p class="keep">
<i>UnicodeCombiningMark</i></p>
<p class="def1-btm">
any
character in the Unicode categories “Non-spacing mark (Mn)” or
“Combining spacing mark (Mc)”</p>
<p class="keep">
<i>UnicodeDigit</i></p>
<p class="def1-btm">
any
character in the Unicode category “Decimal number (Nd)”</p>
<p class="keep">
<i>UnicodeConnectorPunctuation</i></p>
<p class="def1-btm">
any
character in the Unicode category “Connector punctuation (Pc)”</p>
<p class="keep">
<i>UnicodeEscapeSequence</i></p>
<p class="def1-btm">
see
<a href="#x7.8.4">7.8.4</a>.</p>
<h4 id="x7.6.1">7.6.1 Reserved Words <a href="#x7.6.1">#</a> <a href="#x7.6.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h4>
<p>
A
reserved word is an <i>IdentifierName</i>
that cannot be used as an <i>Identifier</i>.</p>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>ReservedWord<b>
</b></i><b>::</b></p>
<p class="def1-btm">
<i>Keyword<br>FutureReservedWord<br>NullLiteral<br>BooleanLiteral</i></p>
<h5 id="x7.6.1.1">7.6.1.1 Keywords <a href="#x7.6.1.1">#</a> <a href="#x7.6.1.1-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
The
following tokens are ECMAScript keywords and may not be used as
<i>Identifiers</i> in
ECMAScript programs.</p>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>Keyword </i>:: <b>one
of</b></p>
<dl><dl><dd>
<table width="590" border="0" cellpadding="8" cellspacing="0"><colgroup><col width="131"><col width="131"><col width="131"><col width="131"></colgroup><tbody><tr valign="TOP"><td width="131" height="3">
<p>
<code><b>break</b></code></p>
</td>
<td width="131">
<p>
<code><b>do
</b></code>
</p>
</td>
<td width="131">
<p>
<code><b>instanceof
</b></code>
</p>
</td>
<td width="131">
<p>
<code><b>typeof
</b></code>
</p>
</td>
</tr><tr valign="TOP"><td width="131" height="3">
<p>
<code><b>case</b></code></p>
</td>
<td width="131">
<p>
<code><b>else</b></code></p>
</td>
<td width="131">
<p>
<code><b>new</b></code></p>
</td>
<td width="131">
<p>
<code><b>var</b></code></p>
</td>
</tr><tr valign="TOP"><td width="131" height="3">
<p>
<code><b>catch</b></code></p>
</td>
<td width="131">
<p>
<code><b>finally</b></code></p>
</td>
<td width="131">
<p>
<code><b>return</b></code></p>
</td>
<td width="131">
<p>
<code><b>void</b></code></p>
</td>
</tr><tr valign="TOP"><td width="131" height="3">
<p>
<code><b>continue</b></code></p>
</td>
<td width="131">
<p>
<code><b>for</b></code></p>
</td>
<td width="131">
<p>
<code><b>switch</b></code></p>
</td>
<td width="131">
<p>
<code><b>while</b></code></p>
</td>
</tr><tr valign="TOP"><td width="131" height="3">
<p class="sm-btm">
<code><b>debugger
</b></code>
</p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>function</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>this</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>with</b></code></p>
</td>
</tr><tr valign="TOP"><td width="131" height="3">
<p class="sm-btm">
<code><b>default</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>if</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>throw</b></code></p>
</td>
<td width="131">
</td>
</tr><tr valign="TOP"><td width="131" height="3">
<p class="sm-btm">
<code><b>delete</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>in</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>try</b></code></p>
</td>
<td width="131">
</td>
</tr></tbody></table></dd></dl></dl><h5 id="x7.6.1.2">7.6.1.2 Future Reserved Words <a href="#x7.6.1.2">#</a> <a href="#x7.6.1.2-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h5>
<p>
The
following words are used as keywords in proposed extensions and are
therefore reserved to allow for the possibility of future adoption
of those extensions.</p>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>FutureReservedWord<b>
</b></i><b>::</b><i><b>
</b></i><b>one
of</b></p>
<dl><dl><dd>
<table width="590" border="0" cellpadding="8" cellspacing="0"><colgroup><col width="131"><col width="131"><col width="131"><col width="131"></colgroup><tbody><tr valign="TOP"><td width="131" height="3">
<p class="sm-btm">
<code><b>class</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>enum</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>extends</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>super</b></code></p>
</td>
</tr><tr valign="TOP"><td width="131" height="3">
<p class="sm-btm">
<code><b>const</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>export</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>import</b></code></p>
</td>
<td width="131">
</td>
</tr></tbody></table></dd></dl></dl><p>
The
following tokens are also considered to be <i>FutureReservedWords</i>
when they occur within <a href="x10.html#x10.1.1" class="term-ref">strict mode code</a> (see <a href="x10.html#x10.1.1">10.1.1</a>). The
occurrence of any of these tokens within <a href="x10.html#x10.1.1" class="term-ref">strict mode code</a> in any
context where the occurrence of a <i>FutureReservedWord</i>
would produce an error must also produce an equivalent error:</p>
<table width="737" border="0" cellpadding="8" cellspacing="0"><colgroup><col width="131"><col width="131"><col width="131"><col width="131"><col width="131"></colgroup><tbody><tr valign="TOP"><td width="131" height="3">
<p class="sm-btm">
<code><b>implements</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>let</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>private</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>public</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>yield</b></code></p>
</td>
</tr><tr valign="TOP"><td width="131" height="3">
<p class="sm-btm">
<code><b>interface</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>package</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>protected</b></code></p>
</td>
<td width="131">
<p class="sm-btm">
<code><b>static</b></code></p>
</td>
<td width="131">
</td>
</tr></tbody></table><h3 id="x7.7">7.7 Punctuators <a href="#x7.7">#</a> <a href="#x7.7-toc" class="bak">Ⓣ</a> <b class="erra">Ⓔ</b> <b class="rev1">①</b> <b class="anno">Ⓐ</b></h3>
<p class="tiny-btm">
<b>Syntax</b></p>
<p class="keep">
<i>Punctuator </i><b>::</b> <b>one
of</b></p>
<dl><dd>
<table width="589" border="0" cellpadding="8" cellspacing="0"><colgroup><col width="82"><col width="82"><col width="82"><col width="82"><col width="82"><col width="82"></colgroup><tbody><tr valign="TOP"><td width="82">
<p>
<code><b>{</b></code></p>
</td>
<td width="82">
<p>
<code><b>}</b></code></p>
</td>
<td width="82">
<p>
<code><b>(</b></code></p>
</td>
<td width="82">
<p>
<code><b>)</b></code></p>
</td>
<td width="82">
<p>
<code><b>[</b></code></p>
</td>
<td width="82">
<p>
<code><b>]</b></code></p>
</td>
</tr><tr valign="TOP"><td width="82">
<p>
<code><b>.</b></code></p>
</td>
<td width="82">
<p>
<code><b>;</b></code></p>
</td>
<td width="82">
<p>
<code><b>,</b></code></p>
</td>
<td width="82">
<p>
<code><b><</b></code></p>
</td>
<td width="82">
<p>
<code><b>></b></code></p>
</td>
<td width="82">
<p>
<code><b><=</b></code></p>
</td>
</tr><tr valign="TOP"><td width="82">
<p>
<code><b>>=</b></code></p>
</td>
<td width="82">
<p>
<code><b>==</b></code></p>
</td>
<td width="82">
<p>
<code><b>!=</b></code></p>
</td>
<td width="82">
<p>
<code><b>===</b></code></p>
</td>
<td width="82">
<p>
<code><b>!==</b></code></p>
</td>
<td width="82">
</td>
</tr><tr valign="TOP"><td width="82">
<p>
<code><b>+</b></code></p>
</td>
<td width="82">
<p>
<code><b>-</b></code></p>
</td>
<td width="82">
<p>
<code><b>*</b></code></p>
</td>
<td width="82">
<p>
<code><b>%</b></code></p>
</td>
<td width="82">
<p>
<code><b>++</b></code></p>
</td>
<td width="82">
<p>
<code><b>--</b></code></p>
</td>
</tr><tr valign="TOP"><td width="82">
<p>
<code><b><<</b></code></p>
</td>
<td width="82">
<p>
<code><b>>></b></code></p>
</td>
<td width="82">
<p>
<code><b>>>></b></code></p>
</td>
<td width="82">
<p>
<code><b>&</b></code></p>
</td>
<td width="82">
<p>
<code><b>|</b></code></p>
</td>
<td width="82">
<p>
<code><b>^</b></code></p>
</td>
</tr><tr valign="TOP"><td width="82">
<p>
<code><b>!</b></code></p>
</td>
<td width="82">
<p>
<code><b>~</b></code></p>
</td>
<td width="82">
<p>
<code><b>&&</b></code></p>
</td>
<td width="82">
<p>
<code><b>||</b></code></p>
</td>
<td width="82">
<p>
<code><b>?</b></code></p>
</td>
<td width="82">
<p>
<code><b>:</b></code></p>
</td>
</tr><tr valign="TOP"><td width="82">
<p>
<code><b>=</b></code></p>