RPA Toolkit
5efeceaa4b6fdeba6bc23b2eb57ab3ed86bccf7c
[rpatk.git] / rjs / ecma262.rpa
1 #!emitall
2 #!emitnone
3 #!emit BitwiseANDOp
4 #!emit BitwiseXOROp
5 #!emit BitwiseOROp
6 #!emit AdditiveExpressionOp
7 #!emit MultiplicativeExpressionOp
8 #!emit ShiftExpressionOp
9 #!emit EqualityExpressionOp
10 #!emit RelationalExpressionOp
11 #!emit LogicalOROp
12 #!emit LogicalANDOp
13
14 #!emit AssignmentOperator
15 #!emit EqualityOperator
16 #!emit RelationalOperator
17 #!emit AdditiveOperator
18 #!emit MultiplicativeOperator
19 #!emit ShiftOperator
20 #!emit BitwiseANDOperator
21 #!emit BitwiseXOROperator
22 #!emit BitwiseOROperator
23 #!emit LogicalANDOperator
24 #!emit LogicalOROperator
25 #!emit LogicalNotOperator
26 #!emit BitwiseNotOperator
27 #!emit UnaryOperator
28
29 #!emit PrefixOperator
30 #!emit PostfixOperator
31 #!emit PostfixExpressionOp
32 #!emit PrefixExpressionOp
33
34 #!emit UnaryExpressionOp
35 #!emit LogicalNotExpressionOp
36 #!emit BitwiseNotExpressionOp
37
38 #!emit DecimalIntegerLiteral
39 #!emit DecimalNonIntegerLiteral
40 #!emit BlockBegin
41 #!emit BlockEnd
42
43 #!emit DoKeyword
44 #!emit IterationDo
45
46 #!emit sqstring
47 #!emit dqstring
48 #!emit DoubleStringCharacters
49 #!emit SingleStringCharacters
50 #!emit Program
51 #!emit Initialiser
52 #!emit AssignmentExpressionOp
53 #!emit AssignmentExpression
54 #!emit LeftHandSideExpression
55 #!emit LeftHandSideExpressionAddr
56 #!emit Expression
57 #!emit MemberExpressionIndexOp
58 #emit MemberExpression
59 #emit NewExpression
60 #!emit MemberExpressionDotOp
61 #!emit IdentifierName
62 #!emit Identifier
63 #!emit CallExpression
64 #!emit VariableAllocate
65 #!emit VariableAllocateAndInit
66 #!emit NewArrayExpression
67
68
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
95
96
97 # 6 Source Text
98 SourceCharacter                 ::= .
99
100 # 7.2 White space
101 WhiteSpace                              ::= [#0x0009] | [#0x000B] | [#0x000C] | [#0x0020] | [#0x00A0] | [#0xFEFF]
102
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> )+
107 SC                                              ::= <S>? ';' <S>?
108 COMMA                                   ::= <S>? ',' <S>?
109 EQ                                              ::= <S>? '=' <S>?
110
111 # 7.4 Comments
112 Comment                                 ::= <MultiLineComment> | <SingleLineComment>
113 MultiLineComment                ::= '/*' <MultiLineCommentChar>* '*/'
114 MultiLineCommentChar    ::= . - '*/'
115 SingleLineComment               ::= '#' <SingleLineCommentChar>*
116 SingleLineCommentChar   ::= <SourceCharacter> - <LineTerminator>
117
118 # 7.5 Tokens
119 Token                                   ::= <IdentifierName> |
120                                                 <NumericLiteral> |
121                                                 <StringLiteral>
122
123 # 7.6 Identifier Names and Identifiers
124
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>
131
132 Lu                                              ::= [#0x0041-#0x005A] | [#0x00C0-#0x00DE] | [#0x0100-#0x0232]   # TBD
133 Ll                                              ::= [#0x0061-#0x007A] | [#0x00C0-#0x00DE]                                               # TBD
134 IdentifierPart                  ::= <IdentifierStart> | 
135                                                 <UnicodeDigit> 
136 UnicodeDigit                    ::= [0-9] | [#0x0660-#0x0669]                                   # TBD
137
138 ReservedWord                    ::= <NullLiteral> |
139                                                         <BooleanLiteral> |
140                                                         <Keyword> |
141                                                         <FutureReservedWord>
142
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'
150
151 FutureReservedWord                      ::= 'class' | 'enum' | 'extends' | 'import' | 'const' | 'export' |
152                                                         'implements' | 'let' | 'private' | 'public' |
153                                 'static' | 'interface' | 'package' | 'protected'
154
155 NullLiteral                                     ::= 'null'
156 BooleanLiteral                          ::= 'true' | 'false'
157 Literal                                         ::= <NullLiteral> |
158                                                         <BooleanLiteral> |
159                                                         <NumericLiteral> |
160                                                         <StringLiteral>
161                                                         
162 LiteralOp                                       ::= <Literal>
163
164 # 7.8.3 Numeric Literals
165
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> |
177                                                                 <DecimalDigits>
178 HexIntegerLiteral                               ::= '0' [xX] <HexDigit>+
179 HexDigit                                                ::= [0-9a-fA-F]
180
181 # 7.8.4 String Literals
182 StringLiteral                                   ::= '"' <DoubleStringCharacters>? '"' |
183                                                                 "'" <SingleStringCharacters>? "'"
184
185 DoubleStringCharacters                  ::= <DoubleStringCharacter>+
186 SingleStringCharacters                  ::= <SingleStringCharacter>+
187
188 DoubleStringCharacter                   ::= <SourceCharacter> - ('"' | '\\' | <LineTerminator>)
189
190 SingleStringCharacter                   ::= <SourceCharacter> - ("'" | '\\' | <LineTerminator>)
191 This                                                    ::= 'this'
192
193 PrimaryExpression                               ::= <This> | 
194                                                                 '(' <S>? <Expression> <S>? ')' |
195                                                                 <Literal> |
196                                                                 <Identifier>
197
198
199
200
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>? ','
206
207
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>
214
215 MemberExpression                                ::= <MemberExpressionIndexOp>  |
216                                                                         <MemberExpressionDotOp> |
217                                                                         <FunctionExpression> |
218                                                                         <PrimaryExpression>
219                                                                         
220                                                                         
221 NewKeyword                                              ::= 'new' - 'new' <IdentifierPart>
222 NewArrayExpression                              ::= <S>? 'new' <S> ( 'Array' | 'Object') <S>? <Arguments>?
223 NewExpression                                   ::= <NewArrayExpression> |
224                                                                         <NewKeyword> <S>? <NewExpression> |
225                                                                         <MemberExpression>
226
227
228 CallExpression                                  ::= <CallExpression> <Arguments> |
229                                                                         <CallExpression> <S>? '[' <S>? Expression <S>? ']' |
230                                                                         <CallExpression> '.' <IdentifierName> |
231                                                                         <MemberExpression> <S>? <Arguments>
232
233 Arguments                                               ::= '(' <S>? ')' |
234                                                                 '(' <S>? <ArgumentList> <S>? ')'
235 ArgumentList                                    ::= <ArgumentList> <S>? ',' <S>? <AssignmentExpression> |
236                                                                         <AssignmentExpression>
237 LeftHandSideExpression                  ::= <CallExpression> | <NewExpression>
238 LeftHandSideExpressionAddr              ::= <CallExpression> | <NewExpression>
239
240
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> 
246
247 PrefixOperator                                  ::= '++' | '--'
248 PrefixExpression                                ::= <PrefixOperator> <LeftHandSideExpression>
249
250 # 11.4 Unary Operators
251 UnaryOperator                                   ::= '~' | '!' | ('+' - '++') | ('-' - '--') | 'delete' | 'void' | 'typeof'
252 UnaryExpressionOp                       ::=     <S>? <UnaryOperator> <S>? <UnaryExpression>
253 UnaryExpression                         ::=     <UnaryExpressionOp> | <PrefixExpression> | <PostfixExpression>
254
255
256 # 11.5 Multiplicative Operators
257 MultiplicativeOperator                  ::= '*' | '/' | '%'
258 MultiplicativeExpressionOp              ::= <MultiplicativeExpression> <S>? <MultiplicativeOperator> <S>? <UnaryExpression>
259 MultiplicativeExpression                ::= <MultiplicativeExpressionOp> | 
260                                                                         <UnaryExpression>
261
262 # 11.6 Additive Operators
263 AdditiveOperator                                ::= '+' | '-'
264 AdditiveExpressionOp                    ::= <AdditiveExpression> <S>? <AdditiveOperator> <S>? <MultiplicativeExpression>
265 AdditiveExpression                              ::= <AdditiveExpressionOp> | 
266                                                                         <MultiplicativeExpression>
267
268
269 11.7 Bitwise Shift Operators
270 ShiftOperator                                   ::= '>>>' | '<<' | '>>'
271 ShiftExpressionOp                               ::= <ShiftExpression> <S>? <ShiftOperator> <S>? <AdditiveExpression>
272 ShiftExpression                                 ::= <ShiftExpressionOp> |
273                                                                 <AdditiveExpression> 
274
275
276 # 11.8 Relational Operators
277 RelationalOperator                              ::= '<=' | '>=' | '<' | '>' | 'instanceof'
278 RelationalExpressionOp                  ::= <RelationalExpression> <S>? <RelationalOperator> <S>? <ShiftExpression>
279 RelationalExpression                    ::= <RelationalExpressionOp> |
280                                                                 <ShiftExpression>
281
282 # 11.9 Equality Operators
283 EqualityOperator                                ::= '===' | '==' | '!==' | '!='
284 EqualityExpressionOp                    ::= <EqualityExpression> <S>? <EqualityOperator> <S>? <RelationalExpression> 
285 EqualityExpression                              ::= <EqualityExpressionOp> |
286                                                                 <RelationalExpression>
287
288 BitwiseANDOperator                              ::= '&' - '&&'
289 BitwiseANDOp                                    ::= <BitwiseANDExpression> <S>? <BitwiseANDOperator> <S>? <EqualityExpression>
290 BitwiseANDExpression                    ::= <BitwiseANDOp> |
291                                                                 <EqualityExpression>
292
293 BitwiseXOROperator                              ::= '^'
294 BitwiseXOROp                                    ::= <BitwiseXORExpression> <S>? <BitwiseXOROperator> <S>? <BitwiseANDExpression>
295 BitwiseXORExpression                    ::= <BitwiseXOROp> |
296                                                                 <BitwiseANDExpression>
297
298 BitwiseOROperator                               ::= '|' - '||'
299 BitwiseOROp                                             ::= <BitwiseORExpression> <S>? <BitwiseOROperator> <S>? <BitwiseXORExpression>
300 BitwiseORExpression                     ::= <BitwiseOROp> |
301                                                                 <BitwiseXORExpression>
302
303 # 11.11 Binary Logical Operators
304 LogicalANDOperator                              ::= '&&'
305 LogicalANDOp                                    ::= <LogicalANDExpression> <S>? <LogicalANDOperator>  <S>? <BitwiseORExpression>
306 LogicalANDExpression                    ::= <LogicalANDOp> |
307                                                                 <BitwiseORExpression>
308
309 LogicalOROperator                               ::= '||'
310 LogicalOROp                                             ::= <LogicalORExpression> <S>? <LogicalOROperator> <S>? <LogicalANDExpression>
311 LogicalORExpression                     ::= <LogicalOROp> |
312                                                                 <LogicalANDExpression>
313
314
315 # 11.12 Conditional Operator ( ? : )
316 ConditionalExpression                   ::= <LogicalORExpression> ( <S>? '?' <S>? <AssignmentExpression> <S>? ':' <S>? <AssignmentExpression> )?
317
318 # 11.13 Assignment Operators
319 AssignmentExpressionOp                  ::= <LeftHandSideExpressionAddr> <S>? <AssignmentOperator> <S>? <AssignmentExpression>
320 AssignmentExpression                    ::= <AssignmentExpressionOp> | <ConditionalExpression>
321 AssignmentOperator                              ::= '=' | '*=' | '/=' | '%=' | '+=' | '-=' | '<<=' | '>>=' | '>>>=' | '&=' | '^=' | '|='
322
323
324 # 11.14 Comma Operator  ( , )
325 Expression                                      ::= <AssignmentExpression> ( <S>? ',' <S>? <AssignmentExpression> )*
326
327
328 # 12 Statements
329 Statement                                               ::= <FunctionDefinitionStatement> |
330                                                                 <ExpressionStatement> |
331                                                                         <ContinueStatement> |
332                                                                         <Block> |
333                                                                 <Comment> |
334                                                                 <VariableStatement> |
335                                                                 <EmptyStatement> |
336                                                                 <IfStatement> |
337                                                                 <IterationStatement> |
338                                                                 <ContinueStatement> |
339                                                                 <BreakStatement> |
340                                                                 <ReturnStatement> |
341                                                                 <WithStatement> |
342                                                                 <SwitchStatementOp>
343
344 # 12.1 Block
345 BlockBegin                                                      ::= <S>? '{' <S>?
346 BlockEnd                                                        ::= <S>? '}' <S>?
347 Block                                                           ::= <BlockBegin> <StatementList>? <BlockEnd>
348 StatementList                                           ::= (<S>? <Statement>)+
349
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>
357
358
359 # 12.3 Empty Statement
360 EmptyStatement                                          ::= <SC>
361
362 # 12.4 Expression Statement
363 ExpressionStatement                             ::= (<Expression> - ('function' | '{')) <SC>
364
365
366 # 12.5 The if Statement
367
368 ElseOp                                                          ::= 'else'
369 IfConditionOp                                           ::= 'if' <S>? '(' <S>? <Expression> <S>? ')'
370 IfOp                                                            ::= <IfConditionOp> <S>? <Statement>
371 IfElseOp                                                        ::= <IfConditionOp> <S>? <Statement> <S>? <ElseOp> <S>? <Statement>
372
373 IfStatement                                                     ::= <IfElseOp> |
374                                                                                 <IfOp>
375
376 # 12.6 Iteration Statements
377 # 12.6a Iteration do ... while() 
378 WhileKeyword                                            ::= 'while'
379 WhileExpression                                         ::= <WhileKeyword> <S>? '(' <S>? <Expression> <S>? ')'
380 DoKeyword                                                       ::= 'do'
381 IterationDo                                                     ::= <DoKeyword> <S>? <Statement> <S>? <WhileExpression> (<S>? ';')
382
383 # 12.6b Iteration while()
384 WhileConditionOp                                        ::= 'while' <S>? '(' <S>? <Expression> <S>? ')'
385 IterationWhileOp                                        ::= <WhileConditionOp> <S>? <Statement>
386
387 # 12.6c Iteration for ( ; ; )
388 ForKeyword                                                      ::= 'for'
389 ExpressionNoIn                                          ::= <Expression>
390 ForExpressionInitOp                                     ::= ('var' <S>? <VariableDeclarationList>) | <ExpressionNoIn>
391 ForExpressionCompareOp                          ::= <Expression>
392 ForExpressionIncrementOp                        ::= <Expression>
393
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>
399
400
401 IterationStatement                                      ::= <IterationWhileOp> |
402                                                                                 <IterationForOp> |
403                                                                         <IterationDo>
404
405 # 12.9 The return Statement
406 ReturnOp                                                        ::= ('return' - 'return' <IdentifierPart>) <WhiteSpace>* <AssignmentExpression>? (<S>? ';')
407 ReturnStatement                                         ::= <ReturnOp>
408
409 # The Break Statement
410 BreakOp                                                         ::= 'break' - 'break' <IdentifierPart>
411 BreakStatement                                          ::= <S>? <BreakOp> <SC>
412
413 # The Continue Statement
414 ContinueOp                                                      ::= 'continue' - 'continue' <IdentifierPart>
415 ContinueStatement                                       ::= <S>? <ContinueOp> <SC>
416
417
418
419 # 12.10 The with Statement
420 WithStatement                                           ::= 'with' <S>? '(' <S>? <Expression> <S>? ')' <S>? <Statement>
421
422
423 # 12.11 The switch Statement
424 SwitchExpressionOp                                      ::= ('switch' - 'switch' <IdentifierPart>) <S>? '(' <S>? <Expression> <S>? ')'
425 SwitchStatementOp                                       ::= <SwitchExpressionOp> <S>? <CaseBlock>
426
427 CaseBlock                                                       ::= '{' <S>? <CaseClauses>? <S>? <DefaultClauseOp>? <S>? <CaseClauses>? <S>? '}' |
428                                                                         '{' <S>? <CaseClauses>? <S>? '}'
429
430
431
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>?
437
438
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>
449
450
451 # 14 Program
452 SourceElements                                  ::= (<S>? <SourceElement>)+
453 SourceElement                                           ::= <FunctionDeclaration> |
454                                                                         <Statement>
455 Program                                                 ::= <SourceElements>
456 # The root rule, it is anonymous
457 <Program>
458
459