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
69 #!uid Program UID_PROGRAM 1
70 #!uid PostfixExpressionValOp UID_POSTFIXEXPRESSIONVALOP 2
71 #!uid Expression UID_EXPRESSION 3
72 #!uid LeftHandSideExpression UID_LEFTHANDSIDEEXPRESSION 4
73 #!uid LeftHandSideExpressionAddr UID_LEFTHANDSIDEEXPRESSIONADDR 5
74 #!uid DecimalIntegerLiteral UID_DECIMALINTEGERLITERAL 6
75 #!uid DecimalNonIntegerLiteral UID_DECIMALNONINTEGERLITERAL 7
76 #!uid AdditiveExpressionOp UID_ADDITIVEEXPRESSIONOP 8
77 #!uid MultiplicativeExpressionOp UID_MULTIPLICATIVEEXPRESSIONOP 9
78 #!uid BitwiseANDOp UID_BITWISEANDOP 10
79 #!uid BitwiseXOROp UID_BITWISEXOROP 11
80 #!uid BitwiseOROp UID_BITWISEOROP 12
81 #!uid ShiftExpressionOp UID_SHIFTEXPRESSIONOP 13
82 #!uid EqualityExpressionOp UID_EQUALITYEXPRESSIONOP 14
83 #!uid RelationalExpressionOp UID_RELATIONALEXPRESSIONOP 15
84 #!uid LogicalOROp UID_LOGICALOROP 16
85 #!uid LogicalANDOp UID_LOGICALANDOP 17
86 #!uid VariableAllocate UID_VARIABLEALLOCATE 18
87 #!uid VariableAllocateAndInit UID_VARIABLEALLOCATEANDINIT 19
88 #!uid IdentifierName UID_IDENTIFIERNAME 20
89 #!uid Identifier UID_IDENTIFIER 21
90 #!uid Initialiser UID_INITIALISER 22
91 #!uid AssignmentExpressionOp UID_ASSIGNMENTEXPRESSIONOP 23
92 #!uid NewArrayExpression UID_NEWARRAYEXPRESSION 24
93 #!uid MemberExpressionDotOp UID_MEMBEREXPRESSIONDOTOP 25
94 #!uid MemberExpressionIndexOp UID_MEMBEREXPRESSIONINDEXOP 26
101 WhiteSpace ::= [#0x0009] | [#0x000B] | [#0x000C] | [#0x0020] | [#0x00A0] | [#0xFEFF]
103 # 7.3 Line Terminators
104 LineTerminator ::= [#0x000D] [#0x000A] | ([#0x000A] | [#0x000D] | [#0x2028] | [#0x2029])
105 LineTerminatorSequence ::= [#0x000D] [#0x000A] | [#0x000A] | [#0x000D] | [#0x2028] | [#0x2029]
106 S ::= ( <WhiteSpace> | <LineTerminator> )+
108 COMMA ::= <S>? ',' <S>?
112 Comment ::= <MultiLineComment> | <SingleLineComment>
113 MultiLineComment ::= '/*' <MultiLineCommentChar>* '*/'
114 MultiLineCommentChar ::= . - '*/'
115 SingleLineComment ::= '#' <SingleLineCommentChar>*
116 SingleLineCommentChar ::= <SourceCharacter> - <LineTerminator>
119 Token ::= <IdentifierName> |
123 # 7.6 Identifier Names and Identifiers
125 Identifier ::= <IdentifierNameNoEmit> - (<ReservedWord> - <ReservedWord> <IdentifierPart>)
126 IdentifierNoEmit ::= <IdentifierNameNoEmit> - (<ReservedWord> - <ReservedWord> <IdentifierPart>)
127 IdentifierName ::= <IdentifierStart> <IdentifierPart>*
128 IdentifierNameNoEmit ::= <IdentifierStart> <IdentifierPart>*
129 IdentifierStart ::= <UnicodeLetter> | '$' | '_' | '\' <UnicodeLetter>
130 UnicodeLetter ::= [#0x0041-#0x005A] | [#0x00C0-#0x00DE] | [#0x0100-#0x0232] | [#0x0061-#0x007A] | [#0x00C0-#0x00DE] # <Lu> | <Ll>
132 Lu ::= [#0x0041-#0x005A] | [#0x00C0-#0x00DE] | [#0x0100-#0x0232] # TBD
133 Ll ::= [#0x0061-#0x007A] | [#0x00C0-#0x00DE] # TBD
134 IdentifierPart ::= <IdentifierStart> |
136 UnicodeDigit ::= [0-9] | [#0x0660-#0x0669] # TBD
138 ReservedWord ::= <NullLiteral> |
143 Keyword ::= 'instanceof' | 'typeof' | 'break' |
144 'do' | 'new' | 'var' |
145 'case' | 'else' | 'return' | 'void' |
146 'catch' | 'finally' | 'continue' | 'for' |
147 'switch' | 'while' | 'this' | 'with' |
148 'debugger' | 'function' | 'throw' | 'default' |
149 'if' | 'try' | 'delete' | 'in'
151 FutureReservedWord ::= 'class' | 'enum' | 'extends' | 'import' | 'const' | 'export' |
152 'implements' | 'let' | 'private' | 'public' |
153 'static' | 'interface' | 'package' | 'protected'
155 NullLiteral ::= 'null'
156 BooleanLiteral ::= 'true' | 'false'
157 Literal ::= <NullLiteral> |
162 LiteralOp ::= <Literal>
164 # 7.8.3 Numeric Literals
166 NumericLiteral ::= <HexIntegerLiteral> | <DecimalNonIntegerLiteral> | <DecimalIntegerLiteral>
167 DecimalNonIntegerLiteral ::= ('0' | <NonZeroDigit> <DecimalDigits>?) '.' <DecimalDigits>? <ExponentPart>? |
168 '.' <DecimalDigits> <ExponentPart>?
169 DecimalIntegerLiteral ::= '0' | <NonZeroDigit> <DecimalDigits>? <ExponentPart>?
170 DecimalDigits ::= <DecimalDigit>+
171 DecimalDigit ::= [0-9]
172 NonZeroDigit ::= [1-9]
173 ExponentPart ::= <ExponentIndicator> <SignedInteger>
174 ExponentIndicator ::= [eE]
175 SignedInteger ::= '-' <DecimalDigits> |
176 '+' <DecimalDigits> |
178 HexIntegerLiteral ::= '0' [xX] <HexDigit>+
179 HexDigit ::= [0-9a-fA-F]
181 # 7.8.4 String Literals
182 StringLiteral ::= '"' <DoubleStringCharacters>? '"' |
183 "'" <SingleStringCharacters>? "'"
185 DoubleStringCharacters ::= <DoubleStringCharacter>+
186 SingleStringCharacters ::= <SingleStringCharacter>+
188 DoubleStringCharacter ::= <SourceCharacter> - ('"' | '\\' | <LineTerminator>)
190 SingleStringCharacter ::= <SourceCharacter> - ("'" | '\\' | <LineTerminator>)
193 PrimaryExpression ::= <This> |
194 '(' <S>? <Expression> <S>? ')' |
201 ArrayLiteral ::= '[' <S>? <Elision>? <S>? ']' |
202 '[' <S>? <ElementList> <S>? ']' |
203 '[' <S>? <ElementList> <S>? ',' <S>? <Elision> <S>? ']'
204 ElementList ::= <Elision>? <S>? <AssignmentExpression> (<S>? ',' <S>? <Elision>? <S>? <AssignmentExpression> )*
205 Elision ::= ',' <S>? <Elision> | <S>? ','
208 # 11.2 Left-Hand-Side Expressions
209 LSB ::= <S>? '[' <S>?
210 RSB ::= <S>? ']' <S>?
211 MemberExpressionBase ::= <MemberExpression>
212 MemberExpressionIndexOp ::= <MemberExpressionBase> <LSB> <Expression> <RSB>
213 MemberExpressionDotOp ::= <MemberExpressionBase> '.' <IdentifierName>
215 MemberExpression ::= <MemberExpressionIndexOp> |
216 <MemberExpressionDotOp> |
217 <FunctionExpression> |
221 NewKeyword ::= 'new' - 'new' <IdentifierPart>
222 NewArrayExpression ::= <S>? 'new' <S> ( 'Array' | 'Object') <S>? <Arguments>?
223 NewExpression ::= <NewArrayExpression> |
224 <NewKeyword> <S>? <NewExpression> |
228 CallExpression ::= <CallExpression> <Arguments> |
229 <CallExpression> <S>? '[' <S>? Expression <S>? ']' |
230 <CallExpression> '.' <IdentifierName> |
231 <MemberExpression> <S>? <Arguments>
233 Arguments ::= '(' <S>? ')' |
234 '(' <S>? <ArgumentList> <S>? ')'
235 ArgumentList ::= <ArgumentList> <S>? ',' <S>? <AssignmentExpression> |
236 <AssignmentExpression>
237 LeftHandSideExpression ::= <CallExpression> | <NewExpression>
238 LeftHandSideExpressionAddr ::= <CallExpression> | <NewExpression>
241 # 11.3 Postfix Expressions
242 # RULE: LeftHandSideExpression always ends up in R0 (Let see if this would work)
243 PostfixOperator ::= '++' | '--'
244 PostfixExpressionOp ::= <LeftHandSideExpression> <PostfixOperator>
245 PostfixExpression ::= <PostfixExpressionOp> | <LeftHandSideExpression>
247 PrefixOperator ::= '++' | '--'
248 PrefixExpression ::= <PrefixOperator> <LeftHandSideExpression>
250 # 11.4 Unary Operators
251 UnaryOperator ::= '~' | '!' | ('+' - '++') | ('-' - '--') | 'delete' | 'void' | 'typeof'
252 UnaryExpressionOp ::= <S>? <UnaryOperator> <S>? <UnaryExpression>
253 UnaryExpression ::= <UnaryExpressionOp> | <PrefixExpression> | <PostfixExpression>
256 # 11.5 Multiplicative Operators
257 MultiplicativeOperator ::= '*' | '/' | '%'
258 MultiplicativeExpressionOp ::= <MultiplicativeExpression> <S>? <MultiplicativeOperator> <S>? <UnaryExpression>
259 MultiplicativeExpression ::= <MultiplicativeExpressionOp> |
262 # 11.6 Additive Operators
263 AdditiveOperator ::= '+' | '-'
264 AdditiveExpressionOp ::= <AdditiveExpression> <S>? <AdditiveOperator> <S>? <MultiplicativeExpression>
265 AdditiveExpression ::= <AdditiveExpressionOp> |
266 <MultiplicativeExpression>
269 11.7 Bitwise Shift Operators
270 ShiftOperator ::= '>>>' | '<<' | '>>'
271 ShiftExpressionOp ::= <ShiftExpression> <S>? <ShiftOperator> <S>? <AdditiveExpression>
272 ShiftExpression ::= <ShiftExpressionOp> |
276 # 11.8 Relational Operators
277 RelationalOperator ::= '<=' | '>=' | '<' | '>' | 'instanceof'
278 RelationalExpressionOp ::= <RelationalExpression> <S>? <RelationalOperator> <S>? <ShiftExpression>
279 RelationalExpression ::= <RelationalExpressionOp> |
282 # 11.9 Equality Operators
283 EqualityOperator ::= '===' | '==' | '!==' | '!='
284 EqualityExpressionOp ::= <EqualityExpression> <S>? <EqualityOperator> <S>? <RelationalExpression>
285 EqualityExpression ::= <EqualityExpressionOp> |
286 <RelationalExpression>
288 BitwiseANDOperator ::= '&' - '&&'
289 BitwiseANDOp ::= <BitwiseANDExpression> <S>? <BitwiseANDOperator> <S>? <EqualityExpression>
290 BitwiseANDExpression ::= <BitwiseANDOp> |
293 BitwiseXOROperator ::= '^'
294 BitwiseXOROp ::= <BitwiseXORExpression> <S>? <BitwiseXOROperator> <S>? <BitwiseANDExpression>
295 BitwiseXORExpression ::= <BitwiseXOROp> |
296 <BitwiseANDExpression>
298 BitwiseOROperator ::= '|' - '||'
299 BitwiseOROp ::= <BitwiseORExpression> <S>? <BitwiseOROperator> <S>? <BitwiseXORExpression>
300 BitwiseORExpression ::= <BitwiseOROp> |
301 <BitwiseXORExpression>
303 # 11.11 Binary Logical Operators
304 LogicalANDOperator ::= '&&'
305 LogicalANDOp ::= <LogicalANDExpression> <S>? <LogicalANDOperator> <S>? <BitwiseORExpression>
306 LogicalANDExpression ::= <LogicalANDOp> |
307 <BitwiseORExpression>
309 LogicalOROperator ::= '||'
310 LogicalOROp ::= <LogicalORExpression> <S>? <LogicalOROperator> <S>? <LogicalANDExpression>
311 LogicalORExpression ::= <LogicalOROp> |
312 <LogicalANDExpression>
315 # 11.12 Conditional Operator ( ? : )
316 ConditionalExpression ::= <LogicalORExpression> ( <S>? '?' <S>? <AssignmentExpression> <S>? ':' <S>? <AssignmentExpression> )?
318 # 11.13 Assignment Operators
319 AssignmentExpressionOp ::= <LeftHandSideExpressionAddr> <S>? <AssignmentOperator> <S>? <AssignmentExpression>
320 AssignmentExpression ::= <AssignmentExpressionOp> | <ConditionalExpression>
321 AssignmentOperator ::= '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
324 # 11.14 Comma Operator ( , )
325 Expression ::= <AssignmentExpression> ( <S>? ',' <S>? <AssignmentExpression> )*
329 Statement ::= <FunctionDefinitionStatement> |
330 <ExpressionStatement> |
331 <ContinueStatement> |
334 <VariableStatement> |
337 <IterationStatement> |
338 <ContinueStatement> |
345 BlockBegin ::= <S>? '{' <S>?
346 BlockEnd ::= <S>? '}' <S>?
347 Block ::= <BlockBegin> <StatementList>? <BlockEnd>
348 StatementList ::= (<S>? <Statement>)+
350 # 12.2 Variable Statement
351 VariableStatement ::= 'var' <S>? <VariableDeclarationList> <SC>
352 VariableDeclarationList ::= <VariableDeclaration> (<COMMA> <VariableDeclaration> )*
353 VariableAllocate ::= <IdentifierNoEmit>
354 VariableAllocateAndInit ::= <IdentifierNoEmit>
355 VariableDeclaration ::= <VariableAllocateAndInit> <Initialiser> | <VariableAllocate>
356 Initialiser ::= <EQ> <AssignmentExpression>
359 # 12.3 Empty Statement
360 EmptyStatement ::= <SC>
362 # 12.4 Expression Statement
363 ExpressionStatement ::= (<Expression> - ('function' | '{')) <SC>
366 # 12.5 The if Statement
369 IfConditionOp ::= 'if' <S>? '(' <S>? <Expression> <S>? ')'
370 IfOp ::= <IfConditionOp> <S>? <Statement>
371 IfElseOp ::= <IfConditionOp> <S>? <Statement> <S>? <ElseOp> <S>? <Statement>
373 IfStatement ::= <IfElseOp> |
376 # 12.6 Iteration Statements
377 # 12.6a Iteration do ... while()
378 WhileKeyword ::= 'while'
379 WhileExpression ::= <WhileKeyword> <S>? '(' <S>? <Expression> <S>? ')'
381 IterationDo ::= <DoKeyword> <S>? <Statement> <S>? <WhileExpression> (<S>? ';')
383 # 12.6b Iteration while()
384 WhileConditionOp ::= 'while' <S>? '(' <S>? <Expression> <S>? ')'
385 IterationWhileOp ::= <WhileConditionOp> <S>? <Statement>
387 # 12.6c Iteration for ( ; ; )
389 ExpressionNoIn ::= <Expression>
390 ForExpressionInitOp ::= ('var' <S>? <VariableDeclarationList>) | <ExpressionNoIn>
391 ForExpressionCompareOp ::= <Expression>
392 ForExpressionIncrementOp ::= <Expression>
394 # The following & expression is done in order to swap the places of the code generated for the comparison and increment.
395 # This is done by selectively turning on/off callbacks in both statement so that the final result appears as if the
396 # <ForExpressionCompareOp> <ForExpressionIncrementOp> appear in the opposite order.
397 ForIterationStatementOp ::= <ForKeyword> <S>? '(' <S>? <ForExpressionInitOp>? <S>? ';' <S>? <ForExpressionCompareOp>? <S>? ';' <S>? <ForExpressionIncrementOp>? <S>? ')'
398 IterationForOp ::= <ForIterationStatementOp> <S>? <Statement>
401 IterationStatement ::= <IterationWhileOp> |
405 # 12.9 The return Statement
406 ReturnOp ::= ('return' - 'return' <IdentifierPart>) <WhiteSpace>* <AssignmentExpression>? (<S>? ';')
407 ReturnStatement ::= <ReturnOp>
409 # The Break Statement
410 BreakOp ::= 'break' - 'break' <IdentifierPart>
411 BreakStatement ::= <S>? <BreakOp> <SC>
413 # The Continue Statement
414 ContinueOp ::= 'continue' - 'continue' <IdentifierPart>
415 ContinueStatement ::= <S>? <ContinueOp> <SC>
419 # 12.10 The with Statement
420 WithStatement ::= 'with' <S>? '(' <S>? <Expression> <S>? ')' <S>? <Statement>
423 # 12.11 The switch Statement
424 SwitchExpressionOp ::= ('switch' - 'switch' <IdentifierPart>) <S>? '(' <S>? <Expression> <S>? ')'
425 SwitchStatementOp ::= <SwitchExpressionOp> <S>? <CaseBlock>
427 CaseBlock ::= '{' <S>? <CaseClauses>? <S>? <DefaultClauseOp>? <S>? <CaseClauses>? <S>? '}' |
428 '{' <S>? <CaseClauses>? <S>? '}'
432 CaseClauses ::= (<S>? <CaseClauseOp>)+
433 CaseExpressionOp ::= ('case' - 'case' <IdentifierPart>) <S>? <Expression> <S>? ':'
434 CaseClauseOp ::= <CaseExpressionOp> <S>? <StatementList>?
435 DefaultKeywordOp ::= 'default' - 'default' <IdentifierPart>
436 DefaultClauseOp ::= <DefaultKeywordOp> <S>? ':' <S>? <StatementList>?
439 # 13 Function Definition
440 FunctionName ::= <Identifier>
441 FunctionNameLookupAlloc ::= <Identifier>
442 FunctionDefinition ::= ('function' - 'function' <IdentifierPart>)<S>?<FunctionName><S>?'('<S>?<FormalParameterList>?<S>?')'
443 FunctionDeclaration ::= <FunctionDefinition><S>?'{'<S>?<FunctionBody>?<S>?'}'
444 FunctionExpression ::= ('function' - 'function'<IdentifierPart>)<S>?<FunctionName>?<S>?'('<S>?<FormalParameterList>?<S>?')'<S>?'{'<S>?<FunctionBody>?<S>?'}'
445 FunctionParameter ::= <Identifier>
446 FormalParameterList ::= <FunctionParameter> ( <S>? ',' <S>? <FunctionParameter> )*
447 FunctionDefinitionStatement ::= ('function' - 'function' <IdentifierPart>)<S>?<FunctionNameLookupAlloc><S>?'('<S>?<FormalParameterList>?<S>?')' <SC>
448 FunctionBody ::= <SourceElements>
452 SourceElements ::= (<S>? <SourceElement>)+
453 SourceElement ::= <FunctionDeclaration> |
455 Program ::= <SourceElements>
456 # The root rule, it is anonymous