]> git.saurik.com Git - cycript.git/blame_incremental - Cycript.y
Remove system.global temporarily, added libffi Depends:, and setup REPL with _ variab...
[cycript.git] / Cycript.y
... / ...
CommitLineData
1%code top {
2#include "Cycript.tab.hh"
3#define scanner driver.scanner_
4#define YYSTACKEXPANDABLE 1
5}
6
7%code requires {
8#include "Parser.hpp"
9
10typedef struct {
11 bool newline_;
12
13 union {
14 bool bool_;
15
16 CYArgument *argument_;
17 CYBoolean *boolean_;
18 CYClause *clause_;
19 CYCatch *catch_;
20 CYCompound *compound_;
21 CYDeclaration *declaration_;
22 CYDeclarations *declarations_;
23 CYElement *element_;
24 CYExpression *expression_;
25 CYFalse *false_;
26 CYField *field_;
27 CYForInitialiser *for_;
28 CYForInInitialiser *forin_;
29 CYFunctionParameter *functionParameter_;
30 CYIdentifier *identifier_;
31 CYLiteral *literal_;
32 CYMessage *message_;
33 CYMessageParameter *messageParameter_;
34 CYName *name_;
35 CYNull *null_;
36 CYNumber *number_;
37 CYProperty *property_;
38 CYSelectorPart *selector_;
39 CYSource *source_;
40 CYStatement *statement_;
41 CYString *string_;
42 CYThis *this_;
43 CYTrue *true_;
44 CYWord *word_;
45 };
46} YYSTYPE;
47
48}
49
50%code provides {
51int cylex(YYSTYPE *lvalp, cy::location *llocp, void *scanner);
52}
53
54%name-prefix "cy"
55
56%language "C++"
57%locations
58
59%initial-action {
60 @$.begin.filename = @$.end.filename = &driver.filename_;
61};
62
63%defines
64
65%debug
66%error-verbose
67
68%parse-param { CYDriver &driver }
69%lex-param { void *scanner }
70
71%token Ampersand "&"
72%token AmpersandAmpersand "&&"
73%token AmpersandEqual "&="
74%token Carrot "^"
75%token CarrotEqual "^="
76%token Equal "="
77%token EqualEqual "=="
78%token EqualEqualEqual "==="
79%token Exclamation "!"
80%token ExclamationEqual "!="
81%token ExclamationEqualEqual "!=="
82%token Hyphen "-"
83%token HyphenEqual "-="
84%token HyphenHyphen "--"
85%token HyphenHyphen_ "\n--"
86%token HyphenRight "->"
87%token Left "<"
88%token LeftEqual "<="
89%token LeftLeft "<<"
90%token LeftLeftEqual "<<="
91%token Percent "%"
92%token PercentEqual "%="
93%token Period "."
94%token Pipe "|"
95%token PipeEqual "|="
96%token PipePipe "||"
97%token Plus "+"
98%token PlusEqual "+="
99%token PlusPlus "++"
100%token PlusPlus_ "\n++"
101%token Right ">"
102%token RightEqual ">="
103%token RightRight ">>"
104%token RightRightEqual ">>="
105%token RightRightRight ">>>"
106%token RightRightRightEqual ">>>="
107%token Slash "/"
108%token SlashEqual "/="
109%token Star "*"
110%token StarEqual "*="
111%token Tilde "~"
112
113%token Colon ":"
114%token Comma ","
115%token Question "?"
116%token SemiColon ";"
117%token NewLine "\n"
118
119%token OpenParen "("
120%token CloseParen ")"
121
122%token OpenBrace "{"
123%token CloseBrace "}"
124
125%token OpenBracket "["
126%token CloseBracket "]"
127
128%token AtClass "@class"
129%token AtSelector "@selector"
130%token AtEnd "@end"
131
132%token <word_> Break "break"
133%token <word_> Case "case"
134%token <word_> Catch "catch"
135%token <word_> Continue "continue"
136%token <word_> Default "default"
137%token <word_> Delete "delete"
138%token <word_> Do "do"
139%token <word_> Else "else"
140%token <false_> False "false"
141%token <word_> Finally "finally"
142%token <word_> For "for"
143%token <word_> Function "function"
144%token <word_> If "if"
145%token <word_> In "in"
146%token <word_> InstanceOf "instanceof"
147%token <word_> New "new"
148%token <null_> Null "null"
149%token <word_> Return "return"
150%token <word_> Switch "switch"
151%token <this_> This "this"
152%token <word_> Throw "throw"
153%token <true_> True "true"
154%token <word_> Try "try"
155%token <word_> TypeOf "typeof"
156%token <word_> Var "var"
157%token <word_> Void "void"
158%token <word_> While "while"
159%token <word_> With "with"
160
161%token <word_> Abstract "abstract"
162%token <word_> Boolean "boolean"
163%token <word_> Byte "byte"
164%token <word_> Char "char"
165%token <word_> Class "class"
166%token <word_> Const "const"
167%token <word_> Debugger "debugger"
168%token <word_> Double "double"
169%token <word_> Enum "enum"
170%token <word_> Export "export"
171%token <word_> Extends "extends"
172%token <word_> Final "final"
173%token <word_> Float "float"
174%token <word_> Goto "goto"
175%token <word_> Implements "implements"
176%token <word_> Import "import"
177%token <word_> Int "int"
178%token <word_> Interface "interface"
179%token <word_> Long "long"
180%token <word_> Native "native"
181%token <word_> Package "package"
182%token <word_> Private "private"
183%token <word_> Protected "protected"
184%token <word_> Public "public"
185%token <word_> Short "short"
186%token <word_> Static "static"
187%token <word_> Super "super"
188%token <word_> Synchronized "synchronized"
189%token <word_> Throws "throws"
190%token <word_> Transient "transient"
191%token <word_> Volatile "volatile"
192
193%token <identifier_> Identifier
194%token <number_> NumericLiteral
195%token <string_> StringLiteral
196
197%type <expression_> AdditiveExpression
198%type <expression_> AdditiveExpressionNoBF
199%type <argument_> ArgumentList
200%type <argument_> ArgumentList_
201%type <argument_> ArgumentListOpt
202%type <argument_> Arguments
203%type <literal_> ArrayLiteral
204%type <expression_> AssignmentExpression
205%type <expression_> AssignmentExpressionNoBF
206%type <expression_> AssignmentExpressionNoIn
207%type <expression_> BitwiseANDExpression
208%type <expression_> BitwiseANDExpressionNoBF
209%type <expression_> BitwiseANDExpressionNoIn
210%type <statement_> Block
211%type <boolean_> BooleanLiteral
212%type <expression_> BitwiseORExpression
213%type <expression_> BitwiseORExpressionNoBF
214%type <expression_> BitwiseORExpressionNoIn
215%type <expression_> BitwiseXORExpression
216%type <expression_> BitwiseXORExpressionNoBF
217%type <expression_> BitwiseXORExpressionNoIn
218%type <statement_> BreakStatement
219%type <expression_> CallExpression
220%type <expression_> CallExpressionNoBF
221%type <clause_> CaseBlock
222%type <clause_> CaseClause
223%type <clause_> CaseClausesOpt
224%type <catch_> CatchOpt
225%type <source_> ClassDeclaration
226%type <message_> ClassMessageDeclaration
227%type <message_> ClassMessageDeclarationListOpt
228%type <expression_> ClassSuperOpt
229%type <field_> ClassFieldList
230%type <expression_> ConditionalExpression
231%type <expression_> ConditionalExpressionNoBF
232%type <expression_> ConditionalExpressionNoIn
233%type <statement_> ContinueStatement
234%type <clause_> DefaultClause
235%type <statement_> DoWhileStatement
236%type <expression_> Element
237%type <expression_> ElementOpt
238%type <element_> ElementList
239%type <element_> ElementListOpt
240%type <statement_> ElseStatementOpt
241%type <statement_> EmptyStatement
242%type <expression_> EqualityExpression
243%type <expression_> EqualityExpressionNoBF
244%type <expression_> EqualityExpressionNoIn
245%type <expression_> Expression
246%type <expression_> ExpressionOpt
247%type <compound_> Expression_
248%type <expression_> ExpressionNoBF
249%type <expression_> ExpressionNoIn
250%type <compound_> ExpressionNoIn_
251%type <expression_> ExpressionNoInOpt
252%type <statement_> ExpressionStatement
253%type <statement_> FinallyOpt
254%type <statement_> ForStatement
255%type <for_> ForStatementInitialiser
256%type <statement_> ForInStatement
257%type <forin_> ForInStatementInitialiser
258%type <functionParameter_> FormalParameterList
259%type <functionParameter_> FormalParameterList_
260%type <source_> FunctionBody
261%type <source_> FunctionDeclaration
262%type <expression_> FunctionExpression
263%type <identifier_> IdentifierOpt
264%type <statement_> IfStatement
265%type <expression_> Initialiser
266%type <expression_> InitialiserOpt
267%type <expression_> InitialiserNoIn
268%type <expression_> InitialiserNoInOpt
269%type <statement_> IterationStatement
270%type <statement_> LabelledStatement
271%type <expression_> LeftHandSideExpression
272%type <expression_> LeftHandSideExpression_
273%type <expression_> LeftHandSideExpressionNoBF
274%type <literal_> Literal
275%type <expression_> LogicalANDExpression
276%type <expression_> LogicalANDExpressionNoBF
277%type <expression_> LogicalANDExpressionNoIn
278%type <expression_> LogicalORExpression
279%type <expression_> LogicalORExpressionNoBF
280%type <expression_> LogicalORExpressionNoIn
281%type <expression_> MemberExpression
282%type <expression_> MemberExpression_
283%type <expression_> MemberExpressionNoBF
284%type <messageParameter_> MessageParameter
285%type <messageParameter_> MessageParameters
286%type <messageParameter_> MessageParameterList
287%type <messageParameter_> MessageParameterListOpt
288%type <bool_> MessageScope
289%type <expression_> MultiplicativeExpression
290%type <expression_> MultiplicativeExpressionNoBF
291%type <expression_> NewExpression
292%type <expression_> NewExpression_
293%type <expression_> NewExpressionNoBF
294%type <null_> NullLiteral
295%type <literal_> ObjectLiteral
296%type <expression_> PostfixExpression
297%type <expression_> PostfixExpressionNoBF
298%type <expression_> PrimaryExpression
299%type <expression_> PrimaryExpression_
300%type <expression_> PrimaryExpressionNoBF
301%type <source_> Program
302%type <name_> PropertyName
303%type <property_> PropertyNameAndValueList
304%type <property_> PropertyNameAndValueList_
305%type <property_> PropertyNameAndValueListOpt
306%type <expression_> RelationalExpression
307%type <expression_> RelationalExpressionNoBF
308%type <expression_> RelationalExpressionNoIn
309%type <statement_> ReturnStatement
310%type <selector_> SelectorExpression
311%type <selector_> SelectorExpression_
312%type <selector_> SelectorExpressionOpt
313%type <expression_> ShiftExpression
314%type <expression_> ShiftExpressionNoBF
315%type <source_> SourceElement
316%type <source_> SourceElements
317%type <statement_> Statement
318%type <statement_> StatementList
319%type <statement_> StatementListOpt
320%type <statement_> SwitchStatement
321%type <statement_> ThrowStatement
322%type <statement_> TryStatement
323%type <expression_> TypeOpt
324%type <expression_> UnaryExpression
325%type <expression_> UnaryExpression_
326%type <expression_> UnaryExpressionNoBF
327%type <declaration_> VariableDeclaration
328%type <declaration_> VariableDeclarationNoIn
329%type <declarations_> VariableDeclarationList
330%type <declarations_> VariableDeclarationList_
331%type <declarations_> VariableDeclarationListNoIn
332%type <declarations_> VariableDeclarationListNoIn_
333%type <statement_> VariableStatement
334%type <statement_> WhileStatement
335%type <statement_> WithStatement
336%type <word_> Word
337%type <word_> WordOpt
338
339%type <expression_> MessageExpression
340%type <argument_> SelectorCall
341%type <argument_> SelectorCall_
342%type <argument_> SelectorList
343%type <argument_> VariadicCall
344
345%left "*" "/" "%"
346%left "+" "-"
347%left "<<" ">>" ">>>"
348%left "<" ">" "<=" ">=" "instanceof" "in"
349%left "==" "!=" "===" "!=="
350%left "&"
351%left "^"
352%left "|"
353%left "&&"
354%left "||"
355
356%right "=" "*=" "/=" "%=" "+=" "-=" "<<=" ">>=" ">>>=" "&=" "^=" "|="
357
358%nonassoc "if"
359%nonassoc "else"
360
361%start Program
362
363%%
364
365TerminatorOpt
366 : ";"
367 | "\n"
368 | error { yyerrok; driver.errors_.pop_back(); }
369 ;
370
371Terminator
372 : ";"
373 | "\n"
374 | error { if (yychar != 0 && yychar != cy::parser::token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } }
375 ;
376
377CommaOpt
378 : ","
379 |
380 ;
381
382NewLineOpt
383 : "\n"
384 |
385 ;
386
387WordOpt
388 : Word { $$ = $1; }
389 | { $$ = NULL; }
390 ;
391
392Word
393 : Identifier { $$ = $1; }
394 | "abstract" { $$ = $1; }
395 | "boolean" { $$ = $1; }
396 | "break" NewLineOpt { $$ = $1; }
397 | "byte" { $$ = $1; }
398 | "case" { $$ = $1; }
399 | "catch" { $$ = $1; }
400 | "char" { $$ = $1; }
401 | "class" { $$ = $1; }
402 | "const" { $$ = $1; }
403 | "continue" NewLineOpt { $$ = $1; }
404 | "debugger" { $$ = $1; }
405 | "default" { $$ = $1; }
406 | "delete" { $$ = $1; }
407 | "do" { $$ = $1; }
408 | "double" { $$ = $1; }
409 | "else" { $$ = $1; }
410 | "enum" { $$ = $1; }
411 | "export" { $$ = $1; }
412 | "extends" { $$ = $1; }
413 | "false" { $$ = $1; }
414 | "final" { $$ = $1; }
415 | "finally" { $$ = $1; }
416 | "float" { $$ = $1; }
417 | "for" { $$ = $1; }
418 | "function" { $$ = $1; }
419 | "goto" { $$ = $1; }
420 | "if" { $$ = $1; }
421 | "implements" { $$ = $1; }
422 | "import" { $$ = $1; }
423 /* XXX: | "in" { $$ = $1; } */
424 /* XXX: | "instanceof" { $$ = $1; } */
425 | "int" { $$ = $1; }
426 | "interface" { $$ = $1; }
427 | "long" { $$ = $1; }
428 | "native" { $$ = $1; }
429 | "new" { $$ = $1; }
430 | "null" { $$ = $1; }
431 | "package" { $$ = $1; }
432 | "private" { $$ = $1; }
433 | "protected" { $$ = $1; }
434 | "public" { $$ = $1; }
435 | "return" NewLineOpt { $$ = $1; }
436 | "short" { $$ = $1; }
437 | "static" { $$ = $1; }
438 | "super" { $$ = $1; }
439 | "switch" { $$ = $1; }
440 | "synchronized" { $$ = $1; }
441 | "this" { $$ = $1; }
442 | "throw" NewLineOpt { $$ = $1; }
443 | "throws" { $$ = $1; }
444 | "transient" { $$ = $1; }
445 | "true" { $$ = $1; }
446 | "try" { $$ = $1; }
447 | "typeof" { $$ = $1; }
448 | "var" { $$ = $1; }
449 | "void" { $$ = $1; }
450 | "volatile" { $$ = $1; }
451 | "while" { $$ = $1; }
452 | "with" { $$ = $1; }
453 ;
454
455IdentifierOpt
456 : Identifier { $$ = $1; }
457 | { $$ = NULL; }
458 ;
459
460Literal
461 : NullLiteral { $$ = $1; }
462 | BooleanLiteral { $$ = $1; }
463 | NumericLiteral { $$ = $1; }
464 | StringLiteral { $$ = $1; }
465 ;
466
467NullLiteral
468 : "null" { $$ = $1; }
469 ;
470
471BooleanLiteral
472 : "true" { $$ = $1; }
473 | "false" { $$ = $1; }
474 ;
475
476/* 11.1 Primary Expressions {{{ */
477PrimaryExpression_
478 : "this" { $$ = $1; }
479 | Identifier { $$ = new(driver.pool_) CYVariable($1); }
480 | Literal { $$ = $1; }
481 | ArrayLiteral { $$ = $1; }
482 | "(" Expression ")" { $$ = $2; }
483 ;
484
485PrimaryExpression
486 : ObjectLiteral { $$ = $1; }
487 | PrimaryExpression_ { $$ = $1; }
488 ;
489
490PrimaryExpressionNoBF
491 : PrimaryExpression_ { $$ = $1; }
492 ;
493/* }}} */
494/* 11.1.4 Array Initialiser {{{ */
495ArrayLiteral
496 : "[" ElementListOpt "]" { $$ = new(driver.pool_) CYArray($2); }
497 ;
498
499Element
500 : AssignmentExpression { $$ = $1; }
501 ;
502
503ElementOpt
504 : Element { $$ = $1; }
505 | { $$ = NULL; }
506 ;
507
508ElementListOpt
509 : ElementList { $$ = $1; }
510 | { $$ = NULL; }
511 ;
512
513ElementList
514 : ElementOpt "," ElementListOpt { $$ = new(driver.pool_) CYElement($1, $3); }
515 | Element { $$ = new(driver.pool_) CYElement($1, NULL); }
516 ;
517/* }}} */
518/* 11.1.5 Object Initialiser {{{ */
519ObjectLiteral
520 : "{" PropertyNameAndValueListOpt "}" { $$ = new(driver.pool_) CYObject($2); }
521 ;
522
523PropertyNameAndValueList_
524 : "," PropertyNameAndValueList { $$ = $2; }
525 | CommaOpt { $$ = NULL; }
526 ;
527
528PropertyNameAndValueListOpt
529 : PropertyNameAndValueList { $$ = $1; }
530 | { $$ = NULL; }
531 ;
532
533PropertyNameAndValueList
534 : PropertyName ":" AssignmentExpression PropertyNameAndValueList_ { $$ = new(driver.pool_) CYProperty($1, $3, $4); }
535 ;
536
537PropertyName
538 : Identifier { $$ = $1; }
539 | StringLiteral { $$ = $1; }
540 | NumericLiteral { $$ = $1; }
541 ;
542/* }}} */
543
544MemberExpression_
545 : "new" MemberExpression Arguments { $$ = new(driver.pool_) CYNew($2, $3); }
546 ;
547
548MemberExpression
549 : PrimaryExpression { $$ = $1; }
550 | FunctionExpression { $$ = $1; }
551 | MemberExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
552 | MemberExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
553 | MemberExpression_ { $$ = $1; }
554 ;
555
556MemberExpressionNoBF
557 : PrimaryExpressionNoBF { $$ = $1; }
558 | MemberExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
559 | MemberExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
560 | MemberExpression_ { $$ = $1; }
561 ;
562
563NewExpression_
564 : "new" NewExpression { $$ = new(driver.pool_) CYNew($2, NULL); }
565 ;
566
567NewExpression
568 : MemberExpression { $$ = $1; }
569 | NewExpression_ { $$ = $1; }
570 ;
571
572NewExpressionNoBF
573 : MemberExpressionNoBF { $$ = $1; }
574 | NewExpression_ { $$ = $1; }
575 ;
576
577CallExpression
578 : MemberExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
579 | CallExpression Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
580 | CallExpression "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
581 | CallExpression "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
582 ;
583
584CallExpressionNoBF
585 : MemberExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
586 | CallExpressionNoBF Arguments { $$ = new(driver.pool_) CYCall($1, $2); }
587 | CallExpressionNoBF "[" Expression "]" { $$ = new(driver.pool_) CYMember($1, $3); }
588 | CallExpressionNoBF "." Identifier { $$ = new(driver.pool_) CYMember($1, new(driver.pool_) CYString($3)); }
589 ;
590
591ArgumentList_
592 : "," ArgumentList { $$ = $2; }
593 | { $$ = NULL; }
594 ;
595
596ArgumentListOpt
597 : ArgumentList { $$ = $1; }
598 | { $$ = NULL; }
599 ;
600
601ArgumentList
602 : AssignmentExpression ArgumentList_ { $$ = new(driver.pool_) CYArgument(NULL, $1, $2); }
603 ;
604
605Arguments
606 : "(" ArgumentListOpt ")" { $$ = $2; }
607 ;
608
609LeftHandSideExpression
610 : NewExpression { $$ = $1; }
611 | CallExpression { $$ = $1; }
612 | LeftHandSideExpression_ { $$ = $1; }
613 ;
614
615LeftHandSideExpressionNoBF
616 : NewExpressionNoBF { $$ = $1; }
617 | CallExpressionNoBF { $$ = $1; }
618 | LeftHandSideExpression_ { $$ = $1; }
619 ;
620
621PostfixExpression
622 : LeftHandSideExpression { $$ = $1; }
623 | LeftHandSideExpression "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
624 | LeftHandSideExpression "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
625 ;
626
627PostfixExpressionNoBF
628 : LeftHandSideExpressionNoBF { $$ = $1; }
629 | LeftHandSideExpressionNoBF "++" { $$ = new(driver.pool_) CYPostIncrement($1); }
630 | LeftHandSideExpressionNoBF "--" { $$ = new(driver.pool_) CYPostDecrement($1); }
631 ;
632
633UnaryExpression_
634 : "delete" UnaryExpression { $$ = new(driver.pool_) CYDelete($2); }
635 | "void" UnaryExpression { $$ = new(driver.pool_) CYVoid($2); }
636 | "typeof" UnaryExpression { $$ = new(driver.pool_) CYTypeOf($2); }
637 | "++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
638 | "\n++" UnaryExpression { $$ = new(driver.pool_) CYPreIncrement($2); }
639 | "--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
640 | "\n--" UnaryExpression { $$ = new(driver.pool_) CYPreDecrement($2); }
641 | "+" UnaryExpression { $$ = $2; }
642 | "-" UnaryExpression { $$ = new(driver.pool_) CYNegate($2); }
643 | "~" UnaryExpression { $$ = new(driver.pool_) CYBitwiseNot($2); }
644 | "!" UnaryExpression { $$ = new(driver.pool_) CYLogicalNot($2); }
645 ;
646
647UnaryExpression
648 : PostfixExpression { $$ = $1; }
649 | UnaryExpression_ { $$ = $1; }
650 ;
651
652UnaryExpressionNoBF
653 : PostfixExpressionNoBF { $$ = $1; }
654 | UnaryExpression_ { $$ = $1; }
655 ;
656
657MultiplicativeExpression
658 : UnaryExpression { $$ = $1; }
659 | MultiplicativeExpression "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
660 | MultiplicativeExpression "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
661 | MultiplicativeExpression "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
662 ;
663
664MultiplicativeExpressionNoBF
665 : UnaryExpressionNoBF { $$ = $1; }
666 | MultiplicativeExpressionNoBF "*" UnaryExpression { $$ = new(driver.pool_) CYMultiply($1, $3); }
667 | MultiplicativeExpressionNoBF "/" UnaryExpression { $$ = new(driver.pool_) CYDivide($1, $3); }
668 | MultiplicativeExpressionNoBF "%" UnaryExpression { $$ = new(driver.pool_) CYModulus($1, $3); }
669 ;
670
671AdditiveExpression
672 : MultiplicativeExpression { $$ = $1; }
673 | AdditiveExpression "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
674 | AdditiveExpression "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
675 ;
676
677AdditiveExpressionNoBF
678 : MultiplicativeExpressionNoBF { $$ = $1; }
679 | AdditiveExpressionNoBF "+" MultiplicativeExpression { $$ = new(driver.pool_) CYAdd($1, $3); }
680 | AdditiveExpressionNoBF "-" MultiplicativeExpression { $$ = new(driver.pool_) CYSubtract($1, $3); }
681 ;
682
683ShiftExpression
684 : AdditiveExpression { $$ = $1; }
685 | ShiftExpression "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
686 | ShiftExpression ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
687 | ShiftExpression ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
688 ;
689
690ShiftExpressionNoBF
691 : AdditiveExpressionNoBF { $$ = $1; }
692 | ShiftExpressionNoBF "<<" AdditiveExpression { $$ = new(driver.pool_) CYShiftLeft($1, $3); }
693 | ShiftExpressionNoBF ">>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightSigned($1, $3); }
694 | ShiftExpressionNoBF ">>>" AdditiveExpression { $$ = new(driver.pool_) CYShiftRightUnsigned($1, $3); }
695 ;
696
697RelationalExpression
698 : ShiftExpression { $$ = $1; }
699 | RelationalExpression "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
700 | RelationalExpression ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
701 | RelationalExpression "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
702 | RelationalExpression ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
703 | RelationalExpression "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
704 | RelationalExpression "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
705 ;
706
707RelationalExpressionNoIn
708 : ShiftExpression { $$ = $1; }
709 | RelationalExpressionNoIn "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
710 | RelationalExpressionNoIn ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
711 | RelationalExpressionNoIn "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
712 | RelationalExpressionNoIn ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
713 | RelationalExpressionNoIn "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
714 ;
715
716RelationalExpressionNoBF
717 : ShiftExpressionNoBF { $$ = $1; }
718 | RelationalExpressionNoBF "<" ShiftExpression { $$ = new(driver.pool_) CYLess($1, $3); }
719 | RelationalExpressionNoBF ">" ShiftExpression { $$ = new(driver.pool_) CYGreater($1, $3); }
720 | RelationalExpressionNoBF "<=" ShiftExpression { $$ = new(driver.pool_) CYLessOrEqual($1, $3); }
721 | RelationalExpressionNoBF ">=" ShiftExpression { $$ = new(driver.pool_) CYGreaterOrEqual($1, $3); }
722 | RelationalExpressionNoBF "instanceof" ShiftExpression { $$ = new(driver.pool_) CYInstanceOf($1, $3); }
723 | RelationalExpressionNoBF "in" ShiftExpression { $$ = new(driver.pool_) CYIn($1, $3); }
724 ;
725
726EqualityExpression
727 : RelationalExpression { $$ = $1; }
728 | EqualityExpression "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
729 | EqualityExpression "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
730 | EqualityExpression "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
731 | EqualityExpression "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
732 ;
733
734EqualityExpressionNoIn
735 : RelationalExpressionNoIn { $$ = $1; }
736 | EqualityExpressionNoIn "==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYEqual($1, $3); }
737 | EqualityExpressionNoIn "!=" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotEqual($1, $3); }
738 | EqualityExpressionNoIn "===" RelationalExpressionNoIn { $$ = new(driver.pool_) CYIdentical($1, $3); }
739 | EqualityExpressionNoIn "!==" RelationalExpressionNoIn { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
740 ;
741
742EqualityExpressionNoBF
743 : RelationalExpressionNoBF { $$ = $1; }
744 | EqualityExpressionNoBF "==" RelationalExpression { $$ = new(driver.pool_) CYEqual($1, $3); }
745 | EqualityExpressionNoBF "!=" RelationalExpression { $$ = new(driver.pool_) CYNotEqual($1, $3); }
746 | EqualityExpressionNoBF "===" RelationalExpression { $$ = new(driver.pool_) CYIdentical($1, $3); }
747 | EqualityExpressionNoBF "!==" RelationalExpression { $$ = new(driver.pool_) CYNotIdentical($1, $3); }
748 ;
749
750BitwiseANDExpression
751 : EqualityExpression { $$ = $1; }
752 | BitwiseANDExpression "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
753 ;
754
755BitwiseANDExpressionNoIn
756 : EqualityExpressionNoIn { $$ = $1; }
757 | BitwiseANDExpressionNoIn "&" EqualityExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
758 ;
759
760BitwiseANDExpressionNoBF
761 : EqualityExpressionNoBF { $$ = $1; }
762 | BitwiseANDExpressionNoBF "&" EqualityExpression { $$ = new(driver.pool_) CYBitwiseAnd($1, $3); }
763 ;
764
765BitwiseXORExpression
766 : BitwiseANDExpression { $$ = $1; }
767 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
768 ;
769
770BitwiseXORExpressionNoIn
771 : BitwiseANDExpressionNoIn { $$ = $1; }
772 | BitwiseXORExpressionNoIn "^" BitwiseANDExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
773 ;
774
775BitwiseXORExpressionNoBF
776 : BitwiseANDExpressionNoBF { $$ = $1; }
777 | BitwiseXORExpressionNoBF "^" BitwiseANDExpression { $$ = new(driver.pool_) CYBitwiseXOr($1, $3); }
778 ;
779
780BitwiseORExpression
781 : BitwiseXORExpression { $$ = $1; }
782 | BitwiseORExpression "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
783 ;
784
785BitwiseORExpressionNoIn
786 : BitwiseXORExpressionNoIn { $$ = $1; }
787 | BitwiseORExpressionNoIn "|" BitwiseXORExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
788 ;
789
790BitwiseORExpressionNoBF
791 : BitwiseXORExpressionNoBF { $$ = $1; }
792 | BitwiseORExpressionNoBF "|" BitwiseXORExpression { $$ = new(driver.pool_) CYBitwiseOr($1, $3); }
793 ;
794
795LogicalANDExpression
796 : BitwiseORExpression { $$ = $1; }
797 | LogicalANDExpression "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
798 ;
799
800LogicalANDExpressionNoIn
801 : BitwiseORExpressionNoIn { $$ = $1; }
802 | LogicalANDExpressionNoIn "&&" BitwiseORExpressionNoIn { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
803 ;
804
805LogicalANDExpressionNoBF
806 : BitwiseORExpressionNoBF { $$ = $1; }
807 | LogicalANDExpressionNoBF "&&" BitwiseORExpression { $$ = new(driver.pool_) CYLogicalAnd($1, $3); }
808 ;
809
810LogicalORExpression
811 : LogicalANDExpression { $$ = $1; }
812 | LogicalORExpression "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
813 ;
814
815LogicalORExpressionNoIn
816 : LogicalANDExpressionNoIn { $$ = $1; }
817 | LogicalORExpressionNoIn "||" LogicalANDExpressionNoIn { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
818 ;
819
820LogicalORExpressionNoBF
821 : LogicalANDExpressionNoBF { $$ = $1; }
822 | LogicalORExpressionNoBF "||" LogicalANDExpression { $$ = new(driver.pool_) CYLogicalOr($1, $3); }
823 ;
824
825ConditionalExpression
826 : LogicalORExpression { $$ = $1; }
827 | LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
828 ;
829
830ConditionalExpressionNoIn
831 : LogicalORExpressionNoIn { $$ = $1; }
832 | LogicalORExpressionNoIn "?" AssignmentExpression ":" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
833 ;
834
835ConditionalExpressionNoBF
836 : LogicalORExpressionNoBF { $$ = $1; }
837 | LogicalORExpressionNoBF "?" AssignmentExpression ":" AssignmentExpression { $$ = new(driver.pool_) CYCondition($1, $3, $5); }
838 ;
839
840AssignmentExpression
841 : ConditionalExpression { $$ = $1; }
842 | LeftHandSideExpression "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
843 | LeftHandSideExpression "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
844 | LeftHandSideExpression "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
845 | LeftHandSideExpression "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
846 | LeftHandSideExpression "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
847 | LeftHandSideExpression "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
848 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
849 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
850 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
851 | LeftHandSideExpression "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
852 | LeftHandSideExpression "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
853 | LeftHandSideExpression "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
854 ;
855
856AssignmentExpressionNoIn
857 : ConditionalExpressionNoIn { $$ = $1; }
858 | LeftHandSideExpression "=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAssign($1, $3); }
859 | LeftHandSideExpression "*=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
860 | LeftHandSideExpression "/=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
861 | LeftHandSideExpression "%=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
862 | LeftHandSideExpression "+=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYAddAssign($1, $3); }
863 | LeftHandSideExpression "-=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
864 | LeftHandSideExpression "<<=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
865 | LeftHandSideExpression ">>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
866 | LeftHandSideExpression ">>>=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
867 | LeftHandSideExpression "&=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
868 | LeftHandSideExpression "^=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
869 | LeftHandSideExpression "|=" AssignmentExpressionNoIn { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
870 ;
871
872AssignmentExpressionNoBF
873 : ConditionalExpressionNoBF { $$ = $1; }
874 | LeftHandSideExpressionNoBF "=" AssignmentExpression { $$ = new(driver.pool_) CYAssign($1, $3); }
875 | LeftHandSideExpressionNoBF "*=" AssignmentExpression { $$ = new(driver.pool_) CYMultiplyAssign($1, $3); }
876 | LeftHandSideExpressionNoBF "/=" AssignmentExpression { $$ = new(driver.pool_) CYDivideAssign($1, $3); }
877 | LeftHandSideExpressionNoBF "%=" AssignmentExpression { $$ = new(driver.pool_) CYModulusAssign($1, $3); }
878 | LeftHandSideExpressionNoBF "+=" AssignmentExpression { $$ = new(driver.pool_) CYAddAssign($1, $3); }
879 | LeftHandSideExpressionNoBF "-=" AssignmentExpression { $$ = new(driver.pool_) CYSubtractAssign($1, $3); }
880 | LeftHandSideExpressionNoBF "<<=" AssignmentExpression { $$ = new(driver.pool_) CYShiftLeftAssign($1, $3); }
881 | LeftHandSideExpressionNoBF ">>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightSignedAssign($1, $3); }
882 | LeftHandSideExpressionNoBF ">>>=" AssignmentExpression { $$ = new(driver.pool_) CYShiftRightUnsignedAssign($1, $3); }
883 | LeftHandSideExpressionNoBF "&=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseAndAssign($1, $3); }
884 | LeftHandSideExpressionNoBF "^=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseXOrAssign($1, $3); }
885 | LeftHandSideExpressionNoBF "|=" AssignmentExpression { $$ = new(driver.pool_) CYBitwiseOrAssign($1, $3); }
886 ;
887
888Expression_
889 : "," Expression { $$ = new(driver.pool_) CYCompound($2); }
890 | { $$ = NULL; }
891 ;
892
893ExpressionNoIn_
894 : "," ExpressionNoIn { $$ = new(driver.pool_) CYCompound($2); }
895 | { $$ = NULL; }
896 ;
897
898ExpressionOpt
899 : Expression { $$ = $1; }
900 | { $$ = NULL; }
901 ;
902
903ExpressionNoInOpt
904 : ExpressionNoIn { $$ = $1; }
905 | { $$ = NULL; }
906 ;
907
908Expression
909 : AssignmentExpression Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
910 ;
911
912ExpressionNoIn
913 : AssignmentExpressionNoIn ExpressionNoIn_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
914 ;
915
916ExpressionNoBF
917 : AssignmentExpressionNoBF Expression_ { if ($2) { $2->AddPrev($1); $$ = $2; } else $$ = $1; }
918 ;
919
920Statement
921 : Block { $$ = $1; }
922 | VariableStatement { $$ = $1; }
923 | EmptyStatement { $$ = $1; }
924 | ExpressionStatement { $$ = $1; }
925 | IfStatement { $$ = $1; }
926 | IterationStatement { $$ = $1; }
927 | ContinueStatement { $$ = $1; }
928 | BreakStatement { $$ = $1; }
929 | ReturnStatement { $$ = $1; }
930 | WithStatement { $$ = $1; }
931 | LabelledStatement { $$ = $1; }
932 | SwitchStatement { $$ = $1; }
933 | ThrowStatement { $$ = $1; }
934 | TryStatement { $$ = $1; }
935 ;
936
937Block
938 : "{" StatementListOpt "}" { $$ = $2 ?: new(driver.pool_) CYEmpty(); }
939 ;
940
941StatementList
942 : Statement StatementListOpt { $1->SetNext($2); $$ = $1; }
943 ;
944
945StatementListOpt
946 : StatementList { $$ = $1; }
947 | { $$ = NULL; }
948 ;
949
950VariableStatement
951 : "var" VariableDeclarationList Terminator { $$ = $2; }
952 ;
953
954VariableDeclarationList_
955 : "," VariableDeclarationList { $$ = $2; }
956 | { $$ = NULL; }
957 ;
958
959VariableDeclarationListNoIn_
960 : "," VariableDeclarationListNoIn { $$ = $2; }
961 | { $$ = NULL; }
962 ;
963
964VariableDeclarationList
965 : VariableDeclaration VariableDeclarationList_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
966 ;
967
968VariableDeclarationListNoIn
969 : VariableDeclarationNoIn VariableDeclarationListNoIn_ { $$ = new(driver.pool_) CYDeclarations($1, $2); }
970 ;
971
972VariableDeclaration
973 : Identifier InitialiserOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
974 ;
975
976VariableDeclarationNoIn
977 : Identifier InitialiserNoInOpt { $$ = new(driver.pool_) CYDeclaration($1, $2); }
978 ;
979
980InitialiserOpt
981 : Initialiser { $$ = $1; }
982 | { $$ = NULL; }
983 ;
984
985InitialiserNoInOpt
986 : InitialiserNoIn { $$ = $1; }
987 | { $$ = NULL; }
988 ;
989
990Initialiser
991 : "=" AssignmentExpression { $$ = $2; }
992 ;
993
994InitialiserNoIn
995 : "=" AssignmentExpressionNoIn { $$ = $2; }
996 ;
997
998EmptyStatement
999 : ";" { $$ = new(driver.pool_) CYEmpty(); }
1000 ;
1001
1002ExpressionStatement
1003 : ExpressionNoBF Terminator { $$ = new(driver.pool_) CYExpress($1); }
1004 ;
1005
1006ElseStatementOpt
1007 : "else" Statement { $$ = $2; }
1008 | %prec "if" { $$ = NULL; }
1009 ;
1010
1011IfStatement
1012 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = new(driver.pool_) CYIf($3, $5, $6); }
1013 ;
1014
1015IterationStatement
1016 : DoWhileStatement { $$ = $1; }
1017 | WhileStatement { $$ = $1; }
1018 | ForStatement { $$ = $1; }
1019 | ForInStatement { $$ = $1; }
1020 ;
1021
1022DoWhileStatement
1023 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = new(driver.pool_) CYDoWhile($5, $2); }
1024 ;
1025
1026WhileStatement
1027 : "while" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWhile($3, $5); }
1028 ;
1029
1030ForStatement
1031 : "for" "(" ForStatementInitialiser ";" ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = new(driver.pool_) CYFor($3, $5, $7, $9); }
1032 ;
1033
1034ForStatementInitialiser
1035 : ExpressionNoInOpt { $$ = $1; }
1036 | "var" VariableDeclarationListNoIn { $$ = $2; }
1037 ;
1038
1039ForInStatement
1040 : "for" "(" ForInStatementInitialiser "in" Expression ")" Statement { $$ = new(driver.pool_) CYForIn($3, $5, $7); }
1041 ;
1042
1043ForInStatementInitialiser
1044 : LeftHandSideExpression { $$ = $1; }
1045 | "var" VariableDeclarationNoIn { $$ = $2; }
1046 ;
1047
1048ContinueStatement
1049 : "continue" IdentifierOpt Terminator { $$ = new(driver.pool_) CYContinue($2); }
1050 ;
1051
1052BreakStatement
1053 : "break" IdentifierOpt Terminator { $$ = new(driver.pool_) CYBreak($2); }
1054 ;
1055
1056ReturnStatement
1057 : "return" ExpressionOpt Terminator { $$ = new(driver.pool_) CYReturn($2); }
1058 ;
1059
1060WithStatement
1061 : "with" "(" Expression ")" Statement { $$ = new(driver.pool_) CYWith($3, $5); }
1062 ;
1063
1064SwitchStatement
1065 : "switch" "(" Expression ")" CaseBlock { $$ = new(driver.pool_) CYSwitch($3, $5); }
1066 ;
1067
1068CaseBlock
1069 : "{" CaseClausesOpt "}" { $$ = $2; }
1070 ;
1071
1072CaseClausesOpt
1073 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1074 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1075 | { $$ = NULL; }
1076 ;
1077
1078CaseClause
1079 : "case" Expression ":" StatementListOpt { $$ = new(driver.pool_) CYClause($2, $4); }
1080 ;
1081
1082DefaultClause
1083 : "default" ":" StatementListOpt { $$ = new(driver.pool_) CYClause(NULL, $3); }
1084 ;
1085
1086LabelledStatement
1087 : Identifier ":" Statement { $3->AddLabel($1); $$ = $3; }
1088 ;
1089
1090ThrowStatement
1091 : "throw" Expression Terminator { $$ = new(driver.pool_) CYThrow($2); }
1092 ;
1093
1094TryStatement
1095 : "try" Block CatchOpt FinallyOpt { $$ = new(driver.pool_) CYTry($2, $3, $4); }
1096 ;
1097
1098CatchOpt
1099 : "catch" "(" Identifier ")" Block { $$ = new(driver.pool_) CYCatch($3, $5); }
1100 | { $$ = NULL; }
1101 ;
1102
1103FinallyOpt
1104 : "finally" Block { $$ = $2; }
1105 | { $$ = NULL; }
1106 ;
1107
1108FunctionDeclaration
1109 : "function" Identifier "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYFunction($2, $4, $7); }
1110 ;
1111
1112FunctionExpression
1113 : "function" IdentifierOpt "(" FormalParameterList ")" "{" FunctionBody "}" { $$ = new(driver.pool_) CYLambda($2, $4, $7); }
1114 ;
1115
1116FormalParameterList_
1117 : "," FormalParameterList { $$ = $2; }
1118 | { $$ = NULL; }
1119 ;
1120
1121FormalParameterList
1122 : Identifier FormalParameterList_ { $$ = new(driver.pool_) CYFunctionParameter($1, $2); }
1123 | { $$ = NULL; }
1124 ;
1125
1126FunctionBody
1127 : SourceElements { $$ = $1; }
1128 ;
1129
1130Program
1131 : SourceElements { driver.source_ = $1; }
1132 ;
1133
1134SourceElements
1135 : SourceElement SourceElements { $1->SetNext($2); $$ = $1; }
1136 | { $$ = NULL; }
1137 ;
1138
1139SourceElement
1140 : Statement { $$ = $1; }
1141 | FunctionDeclaration { $$ = $1; }
1142 ;
1143
1144/* Objective-C Extensions {{{ */
1145ClassSuperOpt
1146 : ":" MemberExpressionNoBF { $$ = $2; }
1147 | { $$ = NULL; }
1148 ;
1149
1150ClassFieldList
1151 : "{" "}" { $$ = NULL; }
1152 ;
1153
1154MessageScope
1155 : "+" { $$ = false; }
1156 | "-" { $$ = true; }
1157 ;
1158
1159TypeOpt
1160 : "(" Expression ")" { $$ = $2; }
1161 | { $$ = NULL; }
1162 ;
1163
1164MessageParameter
1165 : Word ":" TypeOpt Identifier { $$ = new CYMessageParameter($1, $3, $4); }
1166 ;
1167
1168MessageParameterListOpt
1169 : MessageParameterList { $$ = $1; }
1170 | { $$ = NULL; }
1171 ;
1172
1173MessageParameterList
1174 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1175 ;
1176
1177MessageParameters
1178 : MessageParameterList { $$ = $1; }
1179 | Word { $$ = new CYMessageParameter($1, NULL, NULL); }
1180 ;
1181
1182ClassMessageDeclaration
1183 : MessageScope TypeOpt MessageParameters "{" FunctionBody "}" { $$ = new CYMessage($1, $2, $3, $5); }
1184 ;
1185
1186ClassMessageDeclarationListOpt
1187 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1188 | { $$ = NULL; }
1189 ;
1190
1191ClassDeclaration
1192 : "@class" Identifier ClassSuperOpt ClassFieldList ClassMessageDeclarationListOpt "@end" { $$ = new CYClass($2, $3, $4, $5); }
1193 ;
1194
1195SourceElement
1196 : ClassDeclaration { $$ = $1; }
1197 ;
1198
1199VariadicCall
1200 : "," AssignmentExpression VariadicCall { $$ = new(driver.pool_) CYArgument(NULL, $2, $3); }
1201 | { $$ = NULL; }
1202 ;
1203
1204SelectorCall_
1205 : SelectorCall { $$ = $1; }
1206 | VariadicCall { $$ = $1; }
1207 ;
1208
1209SelectorCall
1210 : WordOpt ":" AssignmentExpression SelectorCall_ { $$ = new(driver.pool_) CYArgument($1 ?: new(driver.pool_) CYBlank(), $3, $4); }
1211 ;
1212
1213SelectorList
1214 : SelectorCall { $$ = $1; }
1215 | Word { $$ = new(driver.pool_) CYArgument($1, NULL); }
1216 ;
1217
1218MessageExpression
1219 : "[" AssignmentExpression SelectorList "]" { $$ = new(driver.pool_) CYSend($2, $3); }
1220 ;
1221
1222SelectorExpressionOpt
1223 : SelectorExpression_ { $$ = $1; }
1224 | { $$ = NULL; }
1225 ;
1226
1227SelectorExpression_
1228 : WordOpt ":" SelectorExpressionOpt { $$ = new(driver.pool_) CYSelectorPart($1, true, $3); }
1229 ;
1230
1231SelectorExpression
1232 : SelectorExpression_ { $$ = $1; }
1233 | Word { $$ = new(driver.pool_) CYSelectorPart($1, false, NULL); }
1234 ;
1235
1236PrimaryExpression_
1237 : MessageExpression { $$ = $1; }
1238 | "@selector" "(" SelectorExpression ")" { $$ = new CYSelector($3); }
1239 ;
1240/* }}} */
1241
1242LeftHandSideExpression_
1243 : "*" LeftHandSideExpression { $$ = new(driver.pool_) CYIndirect($2); }
1244 ;
1245
1246UnaryExpression_
1247 : "&" UnaryExpression { $$ = new(driver.pool_) CYAddressOf($2); }
1248 ;
1249
1250%%