5 WhiteSpace ::= [#0x0009] | [#0x000B] | [#0x000C] | [#0x0020] | [#0x00A0] | [#0xFEFF]
8 LineTerminator ::= [#0x000D] [#0x000A] | [#0x000A] | [#0x000D] | [#0x2028] | [#0x2029]
9 LineTerminatorSequence ::= [#0x000D] [#0x000A] |
15 S ::= ( <WhiteSpace> | <LineTerminator> )+
18 Comment ::= <:MultiLineComment:> | <:SingleLineComment:>
19 MultiLineComment ::= '/*' <:MultiLineCommentChar:>* '*/'
20 MultiLineCommentChar ::= . - '*/'
21 SingleLineComment ::= '//' <:SingleLineCommentChar:>*
22 SingleLineCommentChar ::= <:SourceCharacter:> - <:LineTerminator:>
26 Token ::= <:IdentifierName:> |
31 # 7.6 Identifier Names and Identifiers
33 Identifier ::= <IdentifierName> - <ReservedWord> - <ReservedWord> <IdentifierPart>
34 IdentifierName ::= <IdentifierStart> <IdentifierPart>*
35 IdentifierStart ::= <UnicodeLetter> | '$' | '_' | '\' <:UnicodeEscapeSequence:>
36 UnicodeLetter ::= <Lu> |
43 Lu ::= [#0x0041-#0x005A] | [#0x00C0-#0x00DE] | [#0x0100-#0x0232] # TBD
44 Ll ::= [#0x0061-#0x007A] | [#0x00C0-#0x00DE] # TBD
45 IdentifierPart ::= <IdentifierStart> |
46 <:UnicodeCombiningMark:> |
48 <:UnicodeConnectorPunctuation:> # TBD
50 UnicodeDigit ::= [0-9] | [#0x0660-#0x0669] # TBD
51 ReservedWord ::= <:Keyword:>
53 <:FutureReservedWord:> |
57 Keyword ::= 'instanceof' | 'typeof' | 'break' |
58 'do' | 'new' | 'var' |
59 'case' | 'else' | 'return' | 'void' |
60 'catch' | 'finally' | 'continue' | 'for' |
61 'switch' | 'while' | 'this' | 'with' |
62 'debugger' | 'function' | 'throw' | 'default' |
63 'if' | 'try' | 'delete' | 'in'
65 FutureReservedWord ::= 'class' | 'enum' | 'extends' | 'import' | 'const' | 'export' |
66 'implements' | 'let' | 'private' | 'public' |
67 'static' | 'interface' | 'package' | 'protected'
69 NullLiteral ::= 'null'
70 BooleanLiteral ::= 'true' | 'false'
71 Literal ::= <:NullLiteral:> |
75 <:RegularExpressionLiteral:>
80 Punctuator ::= '{' | '}' | '(' | ')' | '[' | ']' |
81 '===' | '!==' | '>=' | '<=' | '==' | '!=' |
82 '<<' | '>>>' | '>>' | '&' | '^=' | '^' |
83 '!' | '~' | '&&' | '||' | '?' | ':' |
84 '>>=' | '>>>=' | '&=' | '|=' |
85 '=' | '+='| '-=' | '*=' | '%=' | '<<=' |
86 '.' | ';' | ',' | '<' | '>' | '|' |
87 '+' | '-' | '*' | '%' | '++' | '--'
88 DivPunctuator ::= '/' | '/='
92 # 7.8.3 Numeric Literals
93 NumericLiteral ::= <:HexIntegerLiteral:> | <:DecimalLiteral:>
94 DecimalLiteral ::= <:DecimalIntegerLiteral:> '.' <:DecimalDigits:>? <:ExponentPart:>? |
95 '.' <:DecimalDigits:> <:ExponentPart:>? |
96 <:DecimalIntegerLiteral:> <:ExponentPart:>?
98 DecimalIntegerLiteral ::= '0' |
99 <:NonZeroDigit:> <:DecimalDigits:>?
101 DecimalDigits ::= <:DecimalDigit:>+
102 DecimalDigit ::= [0-9]
103 NonZeroDigit ::= [1-9]
104 ExponentPart ::= <:ExponentIndicator:> <:SignedInteger:>
105 ExponentIndicator ::= [eE]
106 SignedInteger ::= <:DecimalDigits:> |
107 '+' <:DecimalDigits:> |
108 '-' <:DecimalDigits:>
109 HexIntegerLiteral ::= '0' [xX] <:HexDigit:>+
110 HexDigit ::= [0-9a-fA-F]
113 # 7.8.4 String Literals
115 StringLiteral ::= '"' <:DoubleStringCharacters:>? '"' |
116 "'" <:SingleStringCharacters:>? "'"
118 DoubleStringCharacters ::= <:DoubleStringCharacter:>+
119 SingleStringCharacters ::= <:SingleStringCharacter:>+
122 DoubleStringCharacter ::= '\' <:EscapeSequence:> |
123 <:LineContinuation:> |
124 <:SourceCharacter:> - ('"' | '\' | <:LineTerminator:>)
126 SingleStringCharacter ::= '\' <:EscapeSequence:> |
127 <:LineContinuation:> |
128 <:SourceCharacter:> - ("'" | '\' | <:LineTerminator:>)
130 LineContinuation ::= '\' <:LineTerminatorSequence:>
133 EscapeSequence ::= <:CharacterEscapeSequence:> |
134 '0' ^<:DecimalDigit:> |
135 <:HexEscapeSequence:> |
136 <:UnicodeEscapeSequence:>
138 CharacterEscapeSequence ::= <:SingleEscapeCharacter:> |
139 <:NonEscapeCharacter:>
141 SingleEscapeCharacter ::= "'" | '"' | '\' | [bfnrtv]
142 NonEscapeCharacter ::= <:SourceCharacter:> - (<:EscapeCharacter:> | <:LineTerminator:>)
143 EscapeCharacter ::= <:SingleEscapeCharacter:> |
148 HexEscapeSequence ::= 'x' <:HexDigit:> <:HexDigit:>
149 UnicodeEscapeSequence ::= 'u' <:HexDigit:> <:HexDigit:> <:HexDigit:> <:HexDigit:>
152 # 7.8.5 Regular Expression Literals
153 RegularExpressionLiteral::= '/' <:RegularExpressionBody:> '/' <:RegularExpressionFlags:>
154 RegularExpressionBody ::= <:RegularExpressionFirstChar:> <:RegularExpressionChars:>?
155 RegularExpressionChars ::= <:RegularExpressionChar:>+
156 RegularExpressionFirstChar ::= <:RegularExpressionNonTerminator:> - ( '*' | '\' | '/' | '[' ) |
157 <:RegularExpressionBackslashSequence:> |
158 <:RegularExpressionClass:>
160 RegularExpressionChar ::= <:RegularExpressionNonTerminator:> - ( '\' | '/' | '[') |
161 <:RegularExpressionBackslashSequence:> |
162 <:RegularExpressionClass:>
165 RegularExpressionBackslashSequence ::= '\' <:RegularExpressionNonTerminator:>
166 RegularExpressionNonTerminator ::= <:SourceCharacter:> - <:LineTerminator:>
167 RegularExpressionClass ::= '[' <:RegularExpressionClassChars:> ']'
168 RegularExpressionClassChars ::= <:RegularExpressionClassChar:>+
169 RegularExpressionClassChar ::= <:RegularExpressionNonTerminator:> - ( ']' | '\' ) |
170 <:RegularExpressionBackslashSequence:>
172 RegularExpressionFlags ::= <:IdentifierPart:> <:RegularExpressionFlags:> | <:IdentifierPart:>
174 # 11.1 Primary Expressions
176 PrimaryExpression ::= <:Identifier:> |
180 '(' <S>? <:Expression:> <S>? ')' |
183 ArrayLiteral ::= '[' <S>? <:Elision:>? <S>? ']' |
184 '[' <S>? <:ElementList:> <S>? ']' |
185 '[' <S>? <:ElementList:> <S>? ',' <S>? <:Elision:> <S>? ']'
188 ElementList ::= <:Elision:>? <S>? <:AssignmentExpression:> (<S>? ',' <S>? <:Elision:>? <S>? <:AssignmentExpression:> )*
189 Elision ::= ',' <S>? <:Elision:> | <S>? ','
190 ObjectLiteral ::= '{' <S>? '}' |
191 '{' <S>? <:PropertyNameAndValueList:> <S>? '}' |
192 '{' <S>? <:PropertyNameAndValueList:> <S>? ',' <S>? '}'
194 PropertyNameAndValueList::= <:PropertyAssignment:> ( <S>? ',' <S>? <:PropertyAssignment:>)*
196 PropertyAssignment ::= <:PropertyName:> <S>? ':' <S>? <:AssignmentExpression:> |
197 'get' <S>? <:PropertyName:> <S>? '(' <S>? ')' <S>? '{' <S>? <:FunctionBody:>? <S>? '}' |
198 'set' <S>? <:PropertyName:> <S>? '(' <S>? <:PropertySetParameterList:> <S>? ')' <S>? '{' <S>? <:FunctionBody:>? <S>? '}'
201 PropertyName ::= <:IdentifierName:> |
205 PropertySetParameterList::= <:Identifier:>
208 # 11.2 Left-Hand-Side Expressions
209 MemberExpression ::= <:MemberExpression:> <S>? '[' <S>? <:Expression:> <S>? ']' |
210 <:MemberExpression:> '.' <:IdentifierName:> |
211 'new' <S> <:MemberExpression:> <S>? <:Arguments:> |
212 <:FunctionExpression:> |
213 <:PrimaryExpression:>
215 NewExpression ::= <:NewKeyword:> <S>? <:NewExpression:> |
219 CallExpression ::= <:CallExpression:> <:Arguments:> |
220 <:CallExpression:> <S>? '[' <S>? Expression <S>? ']' |
221 <:CallExpression:> '.' <:IdentifierName:> |
222 <:MemberExpression:> <S>? <:Arguments:>
224 Arguments ::= '(' <S>? ')' |
225 '(' <S>? <:ArgumentList:> <S>? ')'
226 ArgumentList ::= <:ArgumentList:> <S>? ',' <S>? <:AssignmentExpression:> |
227 <:AssignmentExpression:>
228 LeftHandSideExpression ::= <:CallExpression:> | <:NewExpression:>
230 # 11.3 Postfix Expressions
231 PostfixOperator ::= '++' | '--'
232 PostfixExpression ::= <:LeftHandSideExpression:> <:PostfixOperator:>?
234 # 11.4 Unary Operators
235 UnaryOperator ::= 'delete' | 'void' | 'typeof' | '++' | '--' | '+' | '-' | '~' | '!'
236 UnaryExpression ::= <S>? <:UnaryOperator:> <S>? <:UnaryExpression:> | <:PostfixExpression:>
239 # 11.5 Multiplicative Operators
240 MultiplicativeOperator ::= '*' | '/' | '%'
241 MultiplicativeExpressionOp ::= <:MultiplicativeExpression:> <S>? <:MultiplicativeOperator:> <S>? <:UnaryExpression:>
242 MultiplicativeExpression ::= <:MultiplicativeExpressionOp:> |
246 # 11.6 Additive Operators
247 AdditiveOperator ::= '+' | '-'
248 AdditiveExpressionOp ::= <:AdditiveExpression:> <S>? <:AdditiveOperator:> <S>? <:MultiplicativeExpression:>
249 AdditiveExpression ::= <:AdditiveExpressionOp:> |
250 <:MultiplicativeExpression:>
252 11.7 Bitwise Shift Operators
253 ShiftOperator ::= '>>>' | '<<' | '>>'
254 ShiftExpression ::= <:ShiftExpression:> <S>? <:ShiftOperator:> <S>? <:AdditiveExpression:> |
255 <:AdditiveExpression:>
257 # 11.8 Relational Operators
258 RelationalOperatorNoIn ::= '<=' | '>=' | '<' | '>' | 'instanceof'
259 RelationalOperator ::= <:RelationalOperatorNoIn:> | 'in'
260 RelationalExpression ::= <:RelationalExpression:> <S>? <:RelationalOperator:> <S>? <:ShiftExpression:> |
262 RelationalExpressionNoIn::= <:RelationalExpressionNoIn:> <S>? <:RelationalOperatorNoIn:> <S>? <:ShiftExpression:> |
266 # 11.9 Equality Operators
267 EqualityOperator ::= '===' | '==' | '!==' | '!='
268 EqualityExpression ::= <:EqualityExpression:> <S>? <:EqualityOperator:> <S>? <:RelationalExpression:> |
269 <:RelationalExpression:>
270 EqualityExpressionNoIn ::= <:EqualityExpression:> <S>? <:EqualityOperator:> <S>? <:RelationalExpressionNoIn:> |
271 <:RelationalExpressionNoIn:>
273 # 11.10 Binary Bitwise Operators
274 BitwiseANDExpression ::= <:BitwiseANDExpression:> <S>? <:BitwiseANDOperator:> <S>? <:EqualityExpression:> |
275 <:EqualityExpression:>
276 BitwiseANDExpressionNoIn::= <:BitwiseANDExpressionNoIn:> <S>? <:BitwiseANDOperator:> <S>? <:EqualityExpressionNoIn:> |
277 <:EqualityExpressionNoIn:>
278 BitwiseANDOperator ::= '&'
281 BitwiseXORExpression ::= <:BitwiseXORExpression:> <S>? <:BitwiseXOROperator:> <S>? <:BitwiseANDExpression:> |
282 <:BitwiseANDExpression:>
283 BitwiseXORExpressionNoIn::= <:BitwiseXORExpressionNoIn:> <S>? <:BitwiseXOROperator:> <S>? <:BitwiseANDExpressionNoIn:> |
284 <:BitwiseANDExpressionNoIn:>
285 BitwiseXOROperator ::= '^'
287 BitwiseORExpression ::= <:BitwiseORExpression:> <S>? <:BitwiseOROperator:> <S>? <:BitwiseXORExpression:> |
288 <:BitwiseXORExpression:>
289 BitwiseORExpressionNoIn::= <:BitwiseORExpressionNoIn:> <S>? <:BitwiseOROperator:> <S>? <:BitwiseXORExpressionNoIn:> |
290 <:BitwiseXORExpressionNoIn:>
291 BitwiseOROperator ::= '|'
295 # 11.11 Binary Logical Operators
296 LogicalANDExpression ::= <:LogicalANDExpression:> <S>? <:LogicalANDOperator:> <S>? <:BitwiseORExpression:> |
297 <:BitwiseORExpression:>
298 LogicalANDExpressionNoIn::= <:LogicalANDExpressionNoIn:> <S>? <:LogicalANDOperator:> <S>? <:BitwiseORExpressionNoIn:> |
299 <:BitwiseORExpressionNoIn:>
300 LogicalANDOperator ::= '&&'
302 LogicalORExpression ::= <:LogicalORExpression:> <S>? <:LogicalOROperator:> <S>? <:LogicalANDExpression:> |
303 <:LogicalANDExpression:>
304 LogicalORExpressionNoIn ::= <:LogicalORExpressionNoIn:> <S>? <:LogicalOROperator:> <S>? <:LogicalANDExpressionNoIn:> |
305 <:LogicalANDExpressionNoIn:>
306 LogicalOROperator ::= '||'
308 # 11.12 Conditional Operator ( ? : )
309 ConditionalExpression ::= <:LogicalORExpression:> ( <S>? '?' <S>? <:AssignmentExpression:> <S>? ':' <S>? <:AssignmentExpression:> )?
310 ConditionalExpressionNoIn::=<:LogicalORExpressionNoIn:> ( <S>? '?' <S>? <:AssignmentExpression:> <S>? ':' <S>? <:AssignmentExpressionNoIn:> )?
312 # 11.13 Assignment Operators
313 AssignmentExpression ::= <:LeftHandSideExpression:> <S>? <:AssignmentOperator:> <S>? <:AssignmentExpression:> | <:ConditionalExpression:>
314 AssignmentExpressionNoIn::= <:LeftHandSideExpression:> <S>? <:AssignmentOperator:> <S>? <:AssignmentExpressionNoIn:> | <:ConditionalExpressionNoIn:>
315 AssignmentOperator ::= '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
318 # 11.14 Comma Operator ( , )
319 Expression ::= <:AssignmentExpression:> ( <S>? ',' <S>? <:AssignmentExpression:> )*
320 ExpressionNoIn ::= <:AssignmentExpressionNoIn:> ( <S>? ',' <S>? <:AssignmentExpressionNoIn:> )*
325 Statement ::= <:Block:> |
327 <:VariableStatement:> |
329 <:ExpressionStatement:> |
331 <:IterationStatement:> |
332 <:ContinueStatement:> |
334 <:ReturnStatement:> |
335 <:ImportStatement:> |
337 <:LabelledStatement:> |
338 <:SwitchStatement:> |
341 <:DebuggerStatement:>
344 Block ::= '{' <S>? <:StatementList:>? <S>? '}'
345 StatementList ::= (<S>? <:Statement:>)+
347 # 12.2 Variable Statement
348 VariableStatement ::= 'var' <S>? <:VariableDeclarationList:> (<S>? ';')
349 VariableDeclarationList ::= <:VariableDeclaration:> (<S>? ',' <S>? <:VariableDeclaration:> )*
350 VariableDeclarationListNoIn::= <:VariableDeclarationNoIn:> (<S>? ',' <S>? <:VariableDeclarationNoIn:> )*
351 VariableDeclaration ::= <:Identifier:> <:Initialiser:>?
352 VariableDeclarationNoIn ::= <:Identifier:> <:InitialiserNoIn:>?
353 Initialiser ::= <S>? '=' <S>? <:AssignmentExpression:>
354 InitialiserNoIn ::= <S>? '=' <S>? <:AssignmentExpressionNoIn:>
356 # 12.3 Empty Statement
357 EmptyStatement ::= <S>? ';'
360 # 12.4 Expression Statement
361 ExpressionStatement ::= (<:Expression:> - ('function' | '{')) (<S>? ';')
363 12.5 The if Statement
364 IfStatement ::= 'if' <S>? '(' <S>? <:Expression:> <S>? ')'<S>? <:Statement:> <S>? 'else' <S>? <:Statement:> |
365 'if' <S>? '(' <S>? <:Expression:> <S>? ')'<S>? <:Statement:>
370 # 12.6 Iteration Statements
371 IterationStatement ::= 'do' <S>? <:Statement:> <S>? 'while' <S>? '(' <S>? <:Expression:> <S>? ')' (<S>? ';') |
372 'while' <S>? '(' <S>? <:Expression:> <S>? ')' <S>? <:Statement:> |
373 'for' <S>? '(' <S>?'var' <S>? <:VariableDeclarationListNoIn:> <S>? ';' <S>? <:Expression:>? <S>? ';'<S>? <:Expression:>? <S>? ')' <S>? <:Statement:> |
374 'for' <S>? '(' <S>?'var' <S>? <:VariableDeclarationNoIn:> <S>? 'in' <S>? <:Expression:> <S>? ')' <S>? <:Statement:> |
375 'for' <S>? '(' <S>? <:LeftHandSideExpression:> <S>? 'in' <S>? <:Expression:> <S>? ')' <S>? <:Statement:> |
376 'for' <S>? '(' <S>? <:ExpressionNoIn:>? <S>? ';' <S>? <:Expression:>? <S>? ';' <S>? <:Expression:>? <S>? ')' <S>? <:Statement:>
379 # 12.7 The continue Statement
380 ContinueStatement ::= ('continue' - 'continue' <:IdentifierPart:>) <WhiteSpace>* <:Identifier:>? (<S>? ';')
383 # 12.8 The break Statement
384 BreakStatement ::= ('break' - 'break' <:IdentifierPart:>)<WhiteSpace>* <:Identifier:>? (<S>? ';')
387 # 12.9 The return Statement
388 ReturnStatement ::= ('return' - 'return' <:IdentifierPart:>) <WhiteSpace>* <:Expression:>? (<S>? ';')
391 # 12.10 The with Statement
392 WithStatement ::= 'with' <S>? '(' <S>? <:Expression:> <S>? ')' <S>? <:Statement:>
395 # 12.11 The switch Statement
396 SwitchStatement ::= 'switch' <S>? '(' <S>? <:Expression:> <S>? ')' <S>? <:CaseBlock:>
398 CaseBlock ::= '{' <S>? <:CaseClauses:>? <S>? <:DefaultClause:> <S>? <:CaseClauses:>? <S>? '}' |
399 '{' <S>? <:CaseClauses:>? <S>? '}'
403 CaseClauses ::= (<S>? <:CaseClause:>)+
405 CaseClause ::= 'case' <S>? <:Expression:> <S>? ':' <S>? <:StatementList:>?
406 DefaultClause ::= 'default' <S>? ':' <S>? <:StatementList:>
408 # 12.12 Labelled Statements
409 LabelledStatement ::= <:Identifier:> <S>? ':' <S>? <:Statement:>
411 # 12.13 The throw Statement
412 ThrowStatement ::= ('throw' - 'throw' <:IdentifierPart:>) <WhiteSpace>* <:Expression:> (<S>? ';')
414 12.14 The try Statement
415 TryStatement ::= 'try' <S>? <:Block:> <S>? <:Catch:> <S>? <:Finally:> |
416 'try' <S>? <:Block:> <S>? <:Catch:> |
417 'try' <S>? <:Block:> <S>? <:Finally:>
420 Catch ::= 'catch' <S>? '(' <:Identifier:> ')' <S>? <:Block:>
421 Finally ::= 'finally' <S>? <:Block:>
423 # 12.15 The debugger statement
424 DebuggerStatement ::= 'debugger' <S>? ';'
427 # 13 Function Definition
428 FunctionDeclaration ::= ('function'-'function'<:IdentifierPart:>)<S>?<:Identifier:><S>?'('<S>?<:FormalParameterList:>?<S>?')'<S>?'{'<S>?<:FunctionBody:>?<S>?'}'
429 FunctionExpression ::= ('function'-'function'<:IdentifierPart:>)<S>?<:Identifier:>?<S>?'('<S>?<:FormalParameterList:>?<S>?')'<S>?'{'<S>?<:FunctionBody:>?<S>?'}'
430 FormalParameterList ::= <:Identifier:> ( <S>? ',' <S>? <:Identifier:> )*
431 FunctionBody ::= <:SourceElements:>
435 ImportStatement ::= 'import' <:Name:> ( '.' '*' )? (<S>? ';')
436 Name ::= <:IdentifierName:> ( '.' <:IdentifierName:> )*
440 SourceElements ::= (<S>? <:SourceElement:>)+
441 SourceElement ::= <:FunctionDeclaration:> |
443 Program ::= <:SourceElements:>?