6 #!emit AdditiveExpressionOp
7 #!emit MultiplicativeExpressionOp
8 #!emit ShiftExpressionOp
9 #!emit EqualityExpressionOp
10 #!emit RelationalExpressionOp
14 #!emit AssignmentOperator
15 #!emit EqualityOperator
16 #!emit RelationalOperator
17 #!emit AdditiveOperator
18 #!emit MultiplicativeOperator
20 #!emit BitwiseANDOperator
21 #!emit BitwiseXOROperator
22 #!emit BitwiseOROperator
23 #!emit LogicalANDOperator
24 #!emit LogicalOROperator
25 #!emit LogicalNotOperator
26 #!emit BitwiseNotOperator
30 #!emit PostfixOperator
31 #!emit PostfixExpressionOp
32 #!emit PrefixExpressionOp
34 #!emit UnaryExpressionOp
35 #!emit LogicalNotExpressionOp
36 #!emit BitwiseNotExpressionOp
38 #!emit DecimalIntegerLiteral
39 #!emit DecimalNonIntegerLiteral
48 #!emit DoubleStringCharacters
49 #!emit SingleStringCharacters
52 #!emit AssignmentExpressionOp
53 #!emit AssignmentExpression
54 #!emit LeftHandSideExpression
55 #!emit LeftHandSideExpressionAddr
57 #!emit MemberExpressionIndexOp
58 #emit MemberExpression
60 #!emit MemberExpressionDotOp
64 #!emit VariableAllocate
65 #!emit VariableAllocateAndInit
66 #!emit NewArrayExpression
68 #!emit FunctionDeclaration
69 #!emit FunctionParameter
70 #!emit FormalParameterList
73 #!uid Program UID_PROGRAM 1
74 #!uid PostfixExpressionValOp UID_POSTFIXEXPRESSIONVALOP 2
75 #!uid Expression UID_EXPRESSION 3
76 #!uid LeftHandSideExpression UID_LEFTHANDSIDEEXPRESSION 4
77 #!uid LeftHandSideExpressionAddr UID_LEFTHANDSIDEEXPRESSIONADDR 5
78 #!uid DecimalIntegerLiteral UID_DECIMALINTEGERLITERAL 6
79 #!uid DecimalNonIntegerLiteral UID_DECIMALNONINTEGERLITERAL 7
80 #!uid AdditiveExpressionOp UID_ADDITIVEEXPRESSIONOP 8
81 #!uid MultiplicativeExpressionOp UID_MULTIPLICATIVEEXPRESSIONOP 9
82 #!uid BitwiseANDOp UID_BITWISEANDOP 10
83 #!uid BitwiseXOROp UID_BITWISEXOROP 11
84 #!uid BitwiseOROp UID_BITWISEOROP 12
85 #!uid ShiftExpressionOp UID_SHIFTEXPRESSIONOP 13
86 #!uid EqualityExpressionOp UID_EQUALITYEXPRESSIONOP 14
87 #!uid RelationalExpressionOp UID_RELATIONALEXPRESSIONOP 15
88 #!uid LogicalOROp UID_LOGICALOROP 16
89 #!uid LogicalANDOp UID_LOGICALANDOP 17
90 #!uid VariableAllocate UID_VARIABLEALLOCATE 18
91 #!uid VariableAllocateAndInit UID_VARIABLEALLOCATEANDINIT 19
92 #!uid IdentifierName UID_IDENTIFIERNAME 20
93 #!uid Identifier UID_IDENTIFIER 21
94 #!uid Initialiser UID_INITIALISER 22
95 #!uid AssignmentExpressionOp UID_ASSIGNMENTEXPRESSIONOP 23
96 #!uid NewArrayExpression UID_NEWARRAYEXPRESSION 24
97 #!uid MemberExpressionDotOp UID_MEMBEREXPRESSIONDOTOP 25
98 #!uid MemberExpressionIndexOp UID_MEMBEREXPRESSIONINDEXOP 26
99 #!uid FunctionName UID_FUNCTIONNAME 27
100 #!uid FunctionDeclaration UID_FUNCTIONDECLARATION 28
101 #!uid FunctionParameter UID_FUNCTIONPARAMETER 29
102 #!uid FormalParameterList UID_FORMALPARAMETERLIST 30
106 SourceCharacter ::= .
109 WhiteSpace ::= [#0x0009] | [#0x000B] | [#0x000C] | [#0x0020] | [#0x00A0] | [#0xFEFF]
111 # 7.3 Line Terminators
112 LineTerminator ::= [#0x000D] [#0x000A] | ([#0x000A] | [#0x000D] | [#0x2028] | [#0x2029])
113 LineTerminatorSequence ::= [#0x000D] [#0x000A] | [#0x000A] | [#0x000D] | [#0x2028] | [#0x2029]
114 S ::= ( <WhiteSpace> | <LineTerminator> )+
116 COMMA ::= <S>? ',' <S>?
120 Comment ::= <MultiLineComment> | <SingleLineComment>
121 MultiLineComment ::= '/*' <MultiLineCommentChar>* '*/'
122 MultiLineCommentChar ::= . - '*/'
123 SingleLineComment ::= '#' <SingleLineCommentChar>*
124 SingleLineCommentChar ::= <SourceCharacter> - <LineTerminator>
127 Token ::= <IdentifierName> |
131 # 7.6 Identifier Names and Identifiers
133 Identifier ::= <IdentifierNameNoEmit> - (<ReservedWord> - <ReservedWord> <IdentifierPart>)
134 IdentifierNoEmit ::= <IdentifierNameNoEmit> - (<ReservedWord> - <ReservedWord> <IdentifierPart>)
135 IdentifierName ::= <IdentifierStart> <IdentifierPart>*
136 IdentifierNameNoEmit ::= <IdentifierStart> <IdentifierPart>*
137 IdentifierStart ::= <UnicodeLetter> | '$' | '_' | '\' <UnicodeLetter>
138 UnicodeLetter ::= [#0x0041-#0x005A] | [#0x00C0-#0x00DE] | [#0x0100-#0x0232] | [#0x0061-#0x007A] | [#0x00C0-#0x00DE] # <Lu> | <Ll>
140 Lu ::= [#0x0041-#0x005A] | [#0x00C0-#0x00DE] | [#0x0100-#0x0232] # TBD
141 Ll ::= [#0x0061-#0x007A] | [#0x00C0-#0x00DE] # TBD
142 IdentifierPart ::= <IdentifierStart> |
144 UnicodeDigit ::= [0-9] | [#0x0660-#0x0669] # TBD
146 ReservedWord ::= <NullLiteral> |
151 Keyword ::= 'instanceof' | 'typeof' | 'break' |
152 'do' | 'new' | 'var' |
153 'case' | 'else' | 'return' | 'void' |
154 'catch' | 'finally' | 'continue' | 'for' |
155 'switch' | 'while' | 'this' | 'with' |
156 'debugger' | 'function' | 'throw' | 'default' |
157 'if' | 'try' | 'delete' | 'in'
159 FutureReservedWord ::= 'class' | 'enum' | 'extends' | 'import' | 'const' | 'export' |
160 'implements' | 'let' | 'private' | 'public' |
161 'static' | 'interface' | 'package' | 'protected'
163 NullLiteral ::= 'null'
164 BooleanLiteral ::= 'true' | 'false'
165 Literal ::= <NullLiteral> |
170 LiteralOp ::= <Literal>
172 # 7.8.3 Numeric Literals
174 NumericLiteral ::= <HexIntegerLiteral> | <DecimalNonIntegerLiteral> | <DecimalIntegerLiteral>
175 DecimalNonIntegerLiteral ::= ('0' | <NonZeroDigit> <DecimalDigits>?) '.' <DecimalDigits>? <ExponentPart>? |
176 '.' <DecimalDigits> <ExponentPart>?
177 DecimalIntegerLiteral ::= '0' | <NonZeroDigit> <DecimalDigits>? <ExponentPart>?
178 DecimalDigits ::= <DecimalDigit>+
179 DecimalDigit ::= [0-9]
180 NonZeroDigit ::= [1-9]
181 ExponentPart ::= <ExponentIndicator> <SignedInteger>
182 ExponentIndicator ::= [eE]
183 SignedInteger ::= '-' <DecimalDigits> |
184 '+' <DecimalDigits> |
186 HexIntegerLiteral ::= '0' [xX] <HexDigit>+
187 HexDigit ::= [0-9a-fA-F]
189 # 7.8.4 String Literals
190 StringLiteral ::= '"' <DoubleStringCharacters>? '"' |
191 "'" <SingleStringCharacters>? "'"
193 DoubleStringCharacters ::= <DoubleStringCharacter>+
194 SingleStringCharacters ::= <SingleStringCharacter>+
196 DoubleStringCharacter ::= <SourceCharacter> - ('"' | '\\' | <LineTerminator>)
198 SingleStringCharacter ::= <SourceCharacter> - ("'" | '\\' | <LineTerminator>)
201 PrimaryExpression ::= <This> |
202 '(' <S>? <Expression> <S>? ')' |
209 ArrayLiteral ::= '[' <S>? <Elision>? <S>? ']' |
210 '[' <S>? <ElementList> <S>? ']' |
211 '[' <S>? <ElementList> <S>? ',' <S>? <Elision> <S>? ']'
212 ElementList ::= <Elision>? <S>? <AssignmentExpression> (<S>? ',' <S>? <Elision>? <S>? <AssignmentExpression> )*
213 Elision ::= ',' <S>? <Elision> | <S>? ','
216 # 11.2 Left-Hand-Side Expressions
217 LSB ::= <S>? '[' <S>?
218 RSB ::= <S>? ']' <S>?
219 MemberExpressionBase ::= <MemberExpression>
220 MemberExpressionIndexOp ::= <MemberExpressionBase> <LSB> <Expression> <RSB>
221 MemberExpressionDotOp ::= <MemberExpressionBase> '.' <IdentifierName>
223 MemberExpression ::= <MemberExpressionIndexOp> |
224 <MemberExpressionDotOp> |
225 <FunctionExpression> |
229 NewKeyword ::= 'new' - 'new' <IdentifierPart>
230 NewArrayExpression ::= <S>? 'new' <S> ( 'Array' | 'Object') <S>? <Arguments>?
231 NewExpression ::= <NewArrayExpression> |
232 <NewKeyword> <S>? <NewExpression> |
236 CallExpression ::= <CallExpression> <Arguments> |
237 <CallExpression> <S>? '[' <S>? Expression <S>? ']' |
238 <CallExpression> '.' <IdentifierName> |
239 <MemberExpression> <S>? <Arguments>
241 Arguments ::= '(' <S>? ')' |
242 '(' <S>? <ArgumentList> <S>? ')'
243 ArgumentList ::= <ArgumentList> <S>? ',' <S>? <AssignmentExpression> |
244 <AssignmentExpression>
245 LeftHandSideExpression ::= <CallExpression> | <NewExpression>
246 LeftHandSideExpressionAddr ::= <CallExpression> | <NewExpression>
249 # 11.3 Postfix Expressions
250 # RULE: LeftHandSideExpression always ends up in R0 (Let see if this would work)
251 PostfixOperator ::= '++' | '--'
252 PostfixExpressionOp ::= <LeftHandSideExpression> <PostfixOperator>
253 PostfixExpression ::= <PostfixExpressionOp> | <LeftHandSideExpression>
255 PrefixOperator ::= '++' | '--'
256 PrefixExpression ::= <PrefixOperator> <LeftHandSideExpression>
258 # 11.4 Unary Operators
259 UnaryOperator ::= '~' | '!' | ('+' - '++') | ('-' - '--') | 'delete' | 'void' | 'typeof'
260 UnaryExpressionOp ::= <S>? <UnaryOperator> <S>? <UnaryExpression>
261 UnaryExpression ::= <UnaryExpressionOp> | <PrefixExpression> | <PostfixExpression>
264 # 11.5 Multiplicative Operators
265 MultiplicativeOperator ::= '*' | '/' | '%'
266 MultiplicativeExpressionOp ::= <MultiplicativeExpression> <S>? <MultiplicativeOperator> <S>? <UnaryExpression>
267 MultiplicativeExpression ::= <MultiplicativeExpressionOp> |
270 # 11.6 Additive Operators
271 AdditiveOperator ::= '+' | '-'
272 AdditiveExpressionOp ::= <AdditiveExpression> <S>? <AdditiveOperator> <S>? <MultiplicativeExpression>
273 AdditiveExpression ::= <AdditiveExpressionOp> |
274 <MultiplicativeExpression>
277 11.7 Bitwise Shift Operators
278 ShiftOperator ::= '>>>' | '<<' | '>>'
279 ShiftExpressionOp ::= <ShiftExpression> <S>? <ShiftOperator> <S>? <AdditiveExpression>
280 ShiftExpression ::= <ShiftExpressionOp> |
284 # 11.8 Relational Operators
285 RelationalOperator ::= '<=' | '>=' | '<' | '>' | 'instanceof'
286 RelationalExpressionOp ::= <RelationalExpression> <S>? <RelationalOperator> <S>? <ShiftExpression>
287 RelationalExpression ::= <RelationalExpressionOp> |
290 # 11.9 Equality Operators
291 EqualityOperator ::= '===' | '==' | '!==' | '!='
292 EqualityExpressionOp ::= <EqualityExpression> <S>? <EqualityOperator> <S>? <RelationalExpression>
293 EqualityExpression ::= <EqualityExpressionOp> |
294 <RelationalExpression>
296 BitwiseANDOperator ::= '&' - '&&'
297 BitwiseANDOp ::= <BitwiseANDExpression> <S>? <BitwiseANDOperator> <S>? <EqualityExpression>
298 BitwiseANDExpression ::= <BitwiseANDOp> |
301 BitwiseXOROperator ::= '^'
302 BitwiseXOROp ::= <BitwiseXORExpression> <S>? <BitwiseXOROperator> <S>? <BitwiseANDExpression>
303 BitwiseXORExpression ::= <BitwiseXOROp> |
304 <BitwiseANDExpression>
306 BitwiseOROperator ::= '|' - '||'
307 BitwiseOROp ::= <BitwiseORExpression> <S>? <BitwiseOROperator> <S>? <BitwiseXORExpression>
308 BitwiseORExpression ::= <BitwiseOROp> |
309 <BitwiseXORExpression>
311 # 11.11 Binary Logical Operators
312 LogicalANDOperator ::= '&&'
313 LogicalANDOp ::= <LogicalANDExpression> <S>? <LogicalANDOperator> <S>? <BitwiseORExpression>
314 LogicalANDExpression ::= <LogicalANDOp> |
315 <BitwiseORExpression>
317 LogicalOROperator ::= '||'
318 LogicalOROp ::= <LogicalORExpression> <S>? <LogicalOROperator> <S>? <LogicalANDExpression>
319 LogicalORExpression ::= <LogicalOROp> |
320 <LogicalANDExpression>
323 # 11.12 Conditional Operator ( ? : )
324 ConditionalExpression ::= <LogicalORExpression> ( <S>? '?' <S>? <AssignmentExpression> <S>? ':' <S>? <AssignmentExpression> )?
326 # 11.13 Assignment Operators
327 AssignmentExpressionOp ::= <LeftHandSideExpressionAddr> <S>? <AssignmentOperator> <S>? <AssignmentExpression>
328 AssignmentExpression ::= <AssignmentExpressionOp> | <ConditionalExpression>
329 AssignmentOperator ::= '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
332 # 11.14 Comma Operator ( , )
333 Expression ::= <AssignmentExpression> ( <S>? ',' <S>? <AssignmentExpression> )*
337 Statement ::= <FunctionDeclarationStatement> |
338 <ExpressionStatement> |
339 <ContinueStatement> |
342 <VariableStatement> |
345 <IterationStatement> |
346 <ContinueStatement> |
353 BlockBegin ::= <S>? '{' <S>?
354 BlockEnd ::= <S>? '}' <S>?
355 Block ::= <BlockBegin> <StatementList>? <BlockEnd>
356 StatementList ::= (<S>? <Statement>)+
358 # 12.2 Variable Statement
359 VariableStatement ::= 'var' <S>? <VariableDeclarationList> <SC>
360 VariableDeclarationList ::= <VariableDeclaration> (<COMMA> <VariableDeclaration> )*
361 VariableAllocate ::= <IdentifierNoEmit>
362 VariableAllocateAndInit ::= <IdentifierNoEmit>
363 VariableDeclaration ::= <VariableAllocateAndInit> <Initialiser> | <VariableAllocate>
364 Initialiser ::= <EQ> <AssignmentExpression>
367 # 12.3 Empty Statement
368 EmptyStatement ::= <SC>
370 # 12.4 Expression Statement
371 ExpressionStatement ::= (<Expression> - ('function' | '{')) <SC>
374 # 12.5 The if Statement
377 IfConditionOp ::= 'if' <S>? '(' <S>? <Expression> <S>? ')'
378 IfOp ::= <IfConditionOp> <S>? <Statement>
379 IfElseOp ::= <IfConditionOp> <S>? <Statement> <S>? <ElseOp> <S>? <Statement>
381 IfStatement ::= <IfElseOp> |
384 # 12.6 Iteration Statements
385 # 12.6a Iteration do ... while()
386 WhileKeyword ::= 'while'
387 WhileExpression ::= <WhileKeyword> <S>? '(' <S>? <Expression> <S>? ')'
389 IterationDo ::= <DoKeyword> <S>? <Statement> <S>? <WhileExpression> (<S>? ';')
391 # 12.6b Iteration while()
392 WhileConditionOp ::= 'while' <S>? '(' <S>? <Expression> <S>? ')'
393 IterationWhileOp ::= <WhileConditionOp> <S>? <Statement>
395 # 12.6c Iteration for ( ; ; )
397 ExpressionNoIn ::= <Expression>
398 ForExpressionInitOp ::= ('var' <S>? <VariableDeclarationList>) | <ExpressionNoIn>
399 ForExpressionCompareOp ::= <Expression>
400 ForExpressionIncrementOp ::= <Expression>
402 # The following & expression is done in order to swap the places of the code generated for the comparison and increment.
403 # This is done by selectively turning on/off callbacks in both statement so that the final result appears as if the
404 # <ForExpressionCompareOp> <ForExpressionIncrementOp> appear in the opposite order.
405 ForIterationStatementOp ::= <ForKeyword> <S>? '(' <S>? <ForExpressionInitOp>? <S>? ';' <S>? <ForExpressionCompareOp>? <S>? ';' <S>? <ForExpressionIncrementOp>? <S>? ')'
406 IterationForOp ::= <ForIterationStatementOp> <S>? <Statement>
409 IterationStatement ::= <IterationWhileOp> |
413 # 12.9 The return Statement
414 ReturnOp ::= ('return' - 'return' <IdentifierPart>) <WhiteSpace>* <AssignmentExpression>? (<S>? ';')
415 ReturnStatement ::= <ReturnOp>
417 # The Break Statement
418 BreakOp ::= 'break' - 'break' <IdentifierPart>
419 BreakStatement ::= <S>? <BreakOp> <SC>
421 # The Continue Statement
422 ContinueOp ::= 'continue' - 'continue' <IdentifierPart>
423 ContinueStatement ::= <S>? <ContinueOp> <SC>
427 # 12.10 The with Statement
428 WithStatement ::= 'with' <S>? '(' <S>? <Expression> <S>? ')' <S>? <Statement>
431 # 12.11 The switch Statement
432 SwitchExpressionOp ::= ('switch' - 'switch' <IdentifierPart>) <S>? '(' <S>? <Expression> <S>? ')'
433 SwitchStatementOp ::= <SwitchExpressionOp> <S>? <CaseBlock>
435 CaseBlock ::= '{' <S>? <CaseClauses>? <S>? <DefaultClauseOp>? <S>? <CaseClauses>? <S>? '}' |
436 '{' <S>? <CaseClauses>? <S>? '}'
440 CaseClauses ::= (<S>? <CaseClauseOp>)+
441 CaseExpressionOp ::= ('case' - 'case' <IdentifierPart>) <S>? <Expression> <S>? ':'
442 CaseClauseOp ::= <CaseExpressionOp> <S>? <StatementList>?
443 DefaultKeywordOp ::= 'default' - 'default' <IdentifierPart>
444 DefaultClauseOp ::= <DefaultKeywordOp> <S>? ':' <S>? <StatementList>?
447 # 13 Function Definition
448 FunctionName ::= <IdentifierNoEmit>
449 FunctionDeclaration ::= ('function'-'function'<IdentifierPart>)<S>?<FunctionName><S>?'('<S>?<FormalParameterList>?<S>?')'<S>?'{'<S>?<FunctionBody>?<S>?'}'
450 FunctionExpression ::= ('function'-'function'<IdentifierPart>)<S>?<FunctionName>?<S>?'('<S>?<FormalParameterList>?<S>?')'<S>?'{'<S>?<FunctionBody>?<S>?'}'
451 FormalParameterList ::= <FunctionParameter> ( <S>? ',' <S>? <FunctionParameter> )*
452 FunctionParameter ::= <IdentifierNoEmit>
453 FunctionBody ::= <SourceElements>
454 FunctionDeclarationStatement ::= ('function' - 'function' <IdentifierPart>)<S>?<FunctionName><S>?'('<S>?<FormalParameterList>?<S>?')' <SC>
456 # FunctionName ::= <IdentifierNoEmit>
457 # FunctionNameLookupAlloc ::= <IdentifierNoEmit>
458 # FunctionDefinition ::= ('function' - 'function' <IdentifierPart>)<S>?<FunctionName><S>?'('<S>?<FormalParameterList>?<S>?')'
459 # FunctionDeclaration ::= <FunctionDefinition><S>?'{'<S>?<FunctionBody>?<S>?'}'
460 # FunctionExpression ::= ('function' - 'function'<IdentifierPart>)<S>?<FunctionName>?<S>?'('<S>?<FormalParameterList>?<S>?')'<S>?'{'<S>?<FunctionBody>?<S>?'}'
461 # FunctionParameter ::= <Identifier>
462 # FormalParameterList ::= <FunctionParameter> ( <S>? ',' <S>? <FunctionParameter> )*
463 # FunctionDefinitionStatement ::= ('function' - 'function' <IdentifierPart>)<S>?<FunctionNameLookupAlloc><S>?'('<S>?<FormalParameterList>?<S>?')' <SC>
464 # FunctionBody ::= <SourceElements>
468 SourceElements ::= (<S>? <SourceElement>)+
469 SourceElement ::= <FunctionDeclaration> |
471 Program ::= <SourceElements>
472 # The root rule, it is anonymous