forked from erikd/language-javascript
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ecmascript5.txt
554 lines (552 loc) · 26.6 KB
/
ecmascript5.txt
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
Annex A
(informative)
Grammar Summary
A.1 Lexical Grammar
SourceCharacter :: See clause 6
any Unicode code unit
InputElementDiv :: See clause 7
WhiteSpace
LineTerminator
Comment
Token
DivPunctuator
InputElementRegExp :: See clause 7
WhiteSpace
LineTerminator
Comment
Token
RegularExpressionLiteral
WhiteSpace :: See 7.2
<TAB>
<VT>
<FF>
<SP>
<NBSP>
<BOM>
<USP>
LineTerminator :: See 7.3
<LF>
<CR>
<LS>
<PS>
LineTerminatorSequence :: See 7.3
<LF>
<CR> [lookahead ∉ <LF> ]
<LS>
<PS>
<CR> <LF>
Comment :: See 7.4
MultiLineComment
SingleLineComment
MultiLineComment :: See 7.4
/* MultiLineCommentCharsopt */
MultiLineCommentChars :: See 7.4
MultiLineNotAsteriskChar MultiLineCommentCharsopt
* PostAsteriskCommentCharsopt
PostAsteriskCommentChars :: See 7.4
MultiLineNotForwardSlashOrAsteriskChar MultiLineCommentCharsopt
* PostAsteriskCommentCharsopt
MultiLineNotAsteriskChar :: See 7.4
SourceCharacter but not asterisk *
MultiLineNotForwardSlashOrAsteriskChar :: See 7.4
SourceCharacter but not forward-slash / or asterisk *
SingleLineComment :: See 7.4
// SingleLineCommentCharsopt
SingleLineCommentChars :: See 7.4
SingleLineCommentChar SingleLineCommentCharsopt
SingleLineCommentChar :: See 7.4
SourceCharacter but not LineTerminator
Token :: See 7.5
IdentifierName
Punctuator
NumericLiteral
StringLiteral
Identifier :: See 7.6
IdentifierName but not ReservedWord
IdentifierName :: See 7.6
IdentifierStart
IdentifierName IdentifierPart
IdentifierStart :: See 7.6
UnicodeLetter
$
_
\ UnicodeEscapeSequence
IdentifierPart :: See 7.6
IdentifierStart
UnicodeCombiningMark
UnicodeDigit
UnicodeConnectorPunctuation
<ZWNJ>
<ZWJ>
See 7.6
UnicodeLetter
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)”.
See 7.6
UnicodeCombiningMark
any character in the Unicode categories “Non-spacing mark (Mn)” or “Combining
spacing mark (Mc)”
See 7.6
UnicodeDigit
any character in the Unicode category “Decimal number (Nd)”
See 7.6
UnicodeConnectorPunctuation
any character in the Unicode category “Connector punctuation (Pc)”
ReservedWord :: See 7.6.1
Keyword
FutureReservedWord
NullLiteral
BooleanLiteral
Keyword :: one of See 7.6.1.1
instanceof typeof
break do
new var
case else
return void
catch finally
switch while
continue for
this with
debugger function
throw
default if
try
delete in
FutureReservedWord :: one of See 7.6.1.2
extends super
class enum
import
const export
or in strict mode code one of
implements let private public
interface package protected static
yield
Punctuator :: one of See 7.7
) [ ]
{ } (
. ; , < > <=
>= == != === !==
+ - * % ++ --
<< >> >>> & | ^
! ~ && || ? :
= += -= *= %= <<=
>>= >>>= &= |= ^=
DivPunctuator :: one of See 7.7
/ /=
Literal :: See 7.8
NullLiteral
BooleanLiteral
NumericLiteral
StringLiteral
NullLiteral :: See 7.8.1
null
BooleanLiteral :: See 7.8.2
true
false
NumericLiteral :: See 7.8.3
DecimalLiteral
HexIntegerLiteral
DecimalLiteral :: See 7.8.3
DecimalIntegerLiteral . DecimalDigitsopt ExponentPartopt
. DecimalDigits ExponentPartopt
DecimalIntegerLiteral ExponentPartopt
DecimalIntegerLiteral :: See 7.8.3
0
NonZeroDigit DecimalDigitsopt
DecimalDigits :: See 7.8.3
DecimalDigit
DecimalDigits DecimalDigit
DecimalDigit :: one of See 7.8.3
0 1 2 3 4 5 6 7 8 9
ExponentIndicator :: one of See 7.8.3
e E
SignedInteger :: See 7.8.3
DecimalDigits
+ DecimalDigits
- DecimalDigits
HexIntegerLiteral :: See 7.8.3
0x HexDigit
0X HexDigit
HexIntegerLiteral HexDigit
HexDigit :: one of See 7.8.3
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
StringLiteral :: See 7.8.4
" DoubleStringCharactersopt "
' SingleStringCharactersopt '
DoubleStringCharacters :: See 7.8.4
DoubleStringCharacter DoubleStringCharactersopt
SingleStringCharacters :: See 7.8.4
SingleStringCharacter SingleStringCharactersopt
DoubleStringCharacter :: See 7.8.4
SourceCharacter but not double-quote " or backslash \ or LineTerminator
\ EscapeSequence
LineContinuation
SingleStringCharacter :: See 7.8.4
SourceCharacter but not single-quote ' or backslash \ or LineTerminator
\ EscapeSequence
LineContinuation
LineContinuation :: See 7.8.4
\ LineTerminatorSequence
EscapeSequence :: See 7.8.4
CharacterEscapeSequence
0 [lookahead ∉ DecimalDigit]
HexEscapeSequence
UnicodeEscapeSequence
CharacterEscapeSequence :: See 7.8.4
SingleEscapeCharacter
NonEscapeCharacter
SingleEscapeCharacter :: one of See 7.8.4
' " \ b f n r t v
NonEscapeCharacter :: See 7.8.4
SourceCharacter but not EscapeCharacter or LineTerminator
EscapeCharacter :: See 7.8.4
SingleEscapeCharacter
DecimalDigit
x
u
HexEscapeSequence :: See 7.8.4
x HexDigit HexDigit
UnicodeEscapeSequence :: See 7.8.4
u HexDigit HexDigit HexDigit HexDigit
RegularExpressionLiteral :: See 7.8.5
/ RegularExpressionBody / RegularExpressionFlags
RegularExpressionBody :: See 7.8.5
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars :: See 7.8.5
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar :: See 7.8.5
RegularExpressionNonTerminator but not * or \ or / or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionChar :: See 7.8.5
RegularExpressionNonTerminator but not \ or / or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionBackslashSequence :: See 7.8.5
\ NonTerminator
RegularExpressionNonTerminator :: See 7.8.5
SourceCharacter but not LineTerminator
RegularExpressionClass :: See 7.8.5
[ RegularExpressionClassChars ]
RegularExpressionClassChars :: See 7.8.5
[empty]
RegularExpressionClassChars RegularExpressionClassChar
RegularExpressionClassChar :: See 7.8.5
RegularExpressionNonTerminator but not ] or \
RegularExpressionBackslashSequence
RegularExpressionFlags :: See 7.8.5
[empty]
RegularExpressionFlags IdentifierPart
A.2 Number Conversions
StringNumericLiteral ::: See 9.3.1
StrWhiteSpaceopt
StrWhiteSpaceopt StrNumericLiteral StrWhiteSpaceopt
StrWhiteSpace ::: See 9.3.1
StrWhiteSpaceChar StrWhiteSpaceopt
StrWhiteSpaceChar ::: See 9.3.1
WhiteSpace
LineTerminator
StrNumericLiteral ::: See 9.3.1
StrDecimalLiteral
HexIntegerLiteral
StrDecimalLiteral ::: See 9.3.1
StrUnsignedDecimalLiteral
+ StrUnsignedDecimalLiteral
- StrUnsignedDecimalLiteral
StrUnsignedDecimalLiteral ::: See 9.3.1
Infinity
DecimalDigits . DecimalDigitsopt ExponentPartopt
. DecimalDigits ExponentPartopt
DecimalDigits ExponentPartopt
DecimalDigits ::: See 9.3.1
DecimalDigit
DecimalDigits DecimalDigit
DecimalDigit ::: one of See 9.3.1
0 1 2 3 4 5 6 7 8 9
ExponentPart ::: See 9.3.1
ExponentIndicator SignedInteger
ExponentIndicator ::: one of See 9.3.1
e E
SignedInteger ::: See 9.3.1
DecimalDigits
+ DecimalDigits
- DecimalDigits
HexIntegerLiteral ::: See 9.3.1
0x HexDigit
0X HexDigit
HexIntegerLiteral HexDigit
HexDigit ::: one of See 9.3.1
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
A.3 Expressions
PrimaryExpression : See 11.1
this
Identifier
Literal
ArrayLiteral
ObjectLiteral
( Expression )
ArrayLiteral : See 11.1.4
[ Elisionopt ]
[ ElementList ]
[ ElementList , Elisionopt ]
ElementList : See 11.1.4
Elisionopt AssignmentExpression
ElementList , Elisionopt AssignmentExpression
Elision : See 11.1.4
,
Elision ,
ObjectLiteral : See 11.1.5
{ }
{ PropertyNameAndValueList }
{ PropertyNameAndValueList , }
PropertyNameAndValueList : See 11.1.5
PropertyAssignment
PropertyNameAndValueList , PropertyAssignment
PropertyAssignment : See 11.1.5
PropertyName : AssignmentExpression
get PropertyName() { FunctionBody }
set PropertyName( PropertySetParameterList ) { FunctionBody }
PropertyName : See 11.1.5
IdentifierName
StringLiteral
NumericLiteral
PropertySetParameterList : See 11.1.5
Identifier
MemberExpression : See 11.2
PrimaryExpression
FunctionExpression
MemberExpression [ Expression ]
MemberExpression . IdentifierName
new MemberExpression Arguments
NewExpression : See 11.2
MemberExpression
new NewExpression
CallExpression : See 11.2
MemberExpression Arguments
CallExpression Arguments
CallExpression [ Expression ]
CallExpression . IdentifierName
Arguments : See 11.2
()
( ArgumentList )
ArgumentList : See 11.2
AssignmentExpression
ArgumentList , AssignmentExpression
LeftHandSideExpression : See 11.2
NewExpression
CallExpression
PostfixExpression : See 11.3
LeftHandSideExpression
[no LineTerminator here]
LeftHandSideExpression ++
[no LineTerminator here]
LeftHandSideExpression --
UnaryExpression : See 11.4
PostfixExpression
delete UnaryExpression
void UnaryExpression
typeof UnaryExpression
++ UnaryExpression
-- UnaryExpression
+ UnaryExpression
- UnaryExpression
~ UnaryExpression
! UnaryExpression
MultiplicativeExpression : See 11.5
UnaryExpression
MultiplicativeExpression * UnaryExpression
MultiplicativeExpression / UnaryExpression
MultiplicativeExpression % UnaryExpression
AdditiveExpression : See 11.6
MultiplicativeExpression
AdditiveExpression + MultiplicativeExpression
AdditiveExpression - MultiplicativeExpression
ShiftExpression : See 11.7
AdditiveExpression
ShiftExpression << AdditiveExpression
ShiftExpression >> AdditiveExpression
ShiftExpression >>> AdditiveExpression
RelationalExpression : See 11.8
ShiftExpression
RelationalExpression < ShiftExpression
RelationalExpression > ShiftExpression
RelationalExpression <= ShiftExpression
RelationalExpression >= ShiftExpression
RelationalExpression instanceof ShiftExpression
RelationalExpression in ShiftExpression
RelationalExpressionNoIn : See 11.8
ShiftExpression
RelationalExpressionNoIn < ShiftExpression
RelationalExpressionNoIn > ShiftExpression
RelationalExpressionNoIn <= ShiftExpression
RelationalExpressionNoIn >= ShiftExpression
RelationalExpressionNoIn instanceof ShiftExpression
EqualityExpression : See 11.9
RelationalExpression
EqualityExpression == RelationalExpression
EqualityExpression != RelationalExpression
EqualityExpression === RelationalExpression
EqualityExpression !== RelationalExpression
EqualityExpressionNoIn : See 11.9
RelationalExpressionNoIn
EqualityExpressionNoIn == RelationalExpressionNoIn
EqualityExpressionNoIn != RelationalExpressionNoIn
EqualityExpressionNoIn === RelationalExpressionNoIn
EqualityExpressionNoIn !== RelationalExpressionNoIn
BitwiseANDExpression : See 11.10
EqualityExpression
BitwiseANDExpression & EqualityExpression
BitwiseANDExpressionNoIn : See 11.10
EqualityExpressionNoIn
BitwiseANDExpressionNoIn & EqualityExpressionNoIn
BitwiseXORExpression : See 11.10
BitwiseANDExpression
BitwiseXORExpression ^ BitwiseANDExpression
BitwiseXORExpressionNoIn : See 11.10
BitwiseANDExpressionNoIn
BitwiseXORExpressionNoIn ^ BitwiseANDExpressionNoIn
BitwiseORExpression : See 11.10
BitwiseXORExpression
BitwiseORExpression | BitwiseXORExpression
BitwiseORExpressionNoIn : See 11.10
BitwiseXORExpressionNoIn
BitwiseORExpressionNoIn | BitwiseXORExpressionNoIn
LogicalANDExpression : See 11.11
BitwiseORExpression
LogicalANDExpression && BitwiseORExpression
LogicalANDExpressionNoIn : See 11.11
BitwiseORExpressionNoIn
LogicalANDExpressionNoIn && BitwiseORExpressionNoIn
LogicalORExpression : See 11.11
LogicalANDExpression
LogicalORExpression || LogicalANDExpression
LogicalORExpressionNoIn : See 11.11
LogicalANDExpressionNoIn
LogicalORExpressionNoIn || LogicalANDExpressionNoIn
ConditionalExpression : See 11.12
LogicalORExpression
LogicalORExpression ? AssignmentExpression : AssignmentExpression
ConditionalExpressionNoIn : See 11.12
LogicalORExpressionNoIn
LogicalORExpressionNoIn ? AssignmentExpressionNoIn : AssignmentExpressionNoIn
AssignmentExpression : See 11.13
ConditionalExpression
LeftHandSideExpression AssignmentOperator AssignmentExpression
AssignmentExpressionNoIn : See 11.13
ConditionalExpressionNoIn
LeftHandSideExpression AssignmentOperator AssignmentExpressionNoIn
AssignmentOperator : one of See 11.13
-= <<= >>= >>>= &= ^= |=
= *= /= %= +=
Expression : See 11.14
AssignmentExpression
Expression , AssignmentExpression
ExpressionNoIn : See 11.14
AssignmentExpressionNoIn
ExpressionNoIn , AssignmentExpressionNoIn
A.4 Statements
Statement : See clause 12
Block
VariableStatement
EmptyStatement
ExpressionStatement
IfStatement
IterationStatement
ContinueStatement
BreakStatement
ReturnStatement
WithStatement
LabelledStatement
SwitchStatement
ThrowStatement
TryStatement
DebuggerStatement
Block : See 12.1
{ StatementListopt }
StatementList : See 12.1
Statement
StatementList Statement
VariableStatement : See 12.2
var VariableDeclarationList ;
VariableDeclarationList : See 12.2
VariableDeclaration
VariableDeclarationList , VariableDeclaration
VariableDeclarationListNoIn : See 12.2
VariableDeclarationNoIn
VariableDeclarationListNoIn , VariableDeclarationNoIn
VariableDeclaration : See 12.2
Identifier Initialiseropt
VariableDeclarationNoIn : See 12.2
Identifier InitialiserNoInopt
Initialiser : See 12.2
= AssignmentExpression
InitialiserNoIn : See 12.2
= AssignmentExpressionNoIn
EmptyStatement : See 12.3
;
ExpressionStatement : See 12.4
[lookahead ∉ {{, function}] Expression ;
IfStatement : See 12.5
if ( Expression ) Statement else Statement
if ( Expression ) Statement
IterationStatement : See 12.6
do Statement while ( Expression );
while ( Expression ) Statement
for (ExpressionNoInopt; Expressionopt ; Expressionopt ) Statement
for ( var VariableDeclarationListNoIn; Expressionopt ; Expressionopt ) Statement
for ( LeftHandSideExpression in Expression ) Statement
for ( var VariableDeclarationNoIn in Expression ) Statement
ContinueStatement : See 12.7
continue [no LineTerminator here] Identifieropt ;
BreakStatement : See 12.8
break [no LineTerminator here] Identifieropt ;
ReturnStatement : See 12.9
return [no LineTerminator here] Expressionopt ;
WithStatement : See 12.10
with ( Expression ) Statement
SwitchStatement : See 12.11
switch ( Expression ) CaseBlock
CaseBlock : See 12.11
{ CaseClausesopt }
{ CaseClausesopt DefaultClause CaseClausesopt }
CaseClauses : See 12.11
CaseClause
CaseClauses CaseClause
CaseClause : See 12.11
case Expression : StatementListopt
DefaultClause : See 12.11
default : StatementListopt
LabelledStatement : See 12.12
Identifier : Statement
ThrowStatement : See 12.13
throw [no LineTerminator here] Expression ;
TryStatement : See 12.14
try Block Catch
try Block Finally
try Block Catch Finally
Catch : See 12.14
catch ( Identifier ) Block
Finally : See 12.14
finally Block
DebuggerStatement : See 12.15
debugger ;
A.5 Functions and Programs
FunctionDeclaration : See clause 13
function Identifier ( FormalParameterListopt ) { FunctionBody }
FunctionExpression : See clause 13
function Identifieropt ( FormalParameterListopt ) { FunctionBody }
FormalParameterList : See clause 13
Identifier
FormalParameterList , Identifier
FunctionBody : See clause 13
SourceElementsopt
Program : See clause 14
SourceElementsopt
SourceElements : See clause 14
SourceElement
SourceElements SourceElement
SourceElement :
Statement
FunctionDeclaration