]> git.saurik.com Git - cycript.git/blame_incremental - Cycript.yy.in
Add a way to clean all of the Apple architectures.
[cycript.git] / Cycript.yy.in
... / ...
CommitLineData
1/* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2015 Jay Freeman (saurik)
3*/
4
5/* GNU Affero General Public License, Version 3 {{{ */
6/*
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19**/
20/* }}} */
21
22%code top {
23#define cyscanner driver.scanner_
24#define YYSTACKEXPANDABLE 1
25}
26
27%code requires {
28#include "Driver.hpp"
29#include "Parser.hpp"
30#include "Stack.hpp"
31#define CYNew new($pool)
32
33@begin ObjectiveC
34#include "ObjectiveC/Syntax.hpp"
35@end
36
37@begin E4X
38#include "E4X/Syntax.hpp"
39@end
40
41#include "Highlight.hpp"
42
43typedef struct {
44 bool newline_;
45 hi::Value highlight_;
46
47 union {
48 bool bool_;
49
50 CYDriver::Condition condition_;
51
52 CYArgument *argument_;
53 CYAssignment *assignment_;
54 CYBoolean *boolean_;
55 CYClause *clause_;
56 cy::Syntax::Catch *catch_;
57 CYComment *comment_;
58 CYComprehension *comprehension_;
59 CYDeclaration *declaration_;
60 CYDeclarations *declarations_;
61 CYElement *element_;
62 CYExpression *expression_;
63 CYFalse *false_;
64 CYFinally *finally_;
65 CYForInitialiser *for_;
66 CYForInInitialiser *forin_;
67 CYFunctionParameter *functionParameter_;
68 CYIdentifier *identifier_;
69 CYInfix *infix_;
70 CYLiteral *literal_;
71 CYMember *member_;
72 CYModule *module_;
73 CYNull *null_;
74 CYNumber *number_;
75 CYParenthetical *parenthetical_;
76 CYProgram *program_;
77 CYProperty *property_;
78 CYPropertyName *propertyName_;
79 CYRubyProc *rubyProc_;
80 CYStatement *statement_;
81 CYString *string_;
82 CYThis *this_;
83 CYTrue *true_;
84 CYWord *word_;
85
86@begin C
87 CYTypeModifier *modifier_;
88 CYTypeSpecifier *specifier_;
89 CYTypedIdentifier *typedIdentifier_;
90 CYTypedParameter *typedParameter_;
91@end
92
93@begin ObjectiveC
94 CYClassName *className_;
95 CYClassField *classField_;
96 CYMessage *message_;
97 CYMessageParameter *messageParameter_;
98 CYProtocol *protocol_;
99 CYSelectorPart *selector_;
100@end
101
102@begin E4X
103 CYAttribute *attribute_;
104 CYPropertyIdentifier *propertyIdentifier_;
105 CYSelector *selector_;
106@end
107 };
108} YYSTYPE;
109
110#define YYSTYPE YYSTYPE
111}
112
113%code provides {
114int cylex(YYSTYPE *, CYLocation *, void *);
115}
116
117%name-prefix "cy"
118
119%language "C++"
120
121%initial-action {
122 @$.begin.filename = @$.end.filename = &driver.filename_;
123};
124
125%locations
126%defines
127
128%define api.location.type { CYLocation }
129
130//%glr-parser
131//%expect 1
132
133%error-verbose
134
135%parse-param { CYDriver &driver }
136%lex-param { void *cyscanner }
137
138/* Token Declarations {{{ */
139@begin E4X
140%token XMLCDATA
141%token XMLComment
142%token XMLPI
143
144%token XMLAttributeValue
145%token XMLName
146%token XMLTagCharacters
147%token XMLText
148%token XMLWhitespace
149@end
150
151@begin E4X
152%token LeftRight "<>"
153%token LeftSlashRight "</>"
154
155%token SlashRight "/>"
156%token LeftSlash "</"
157
158%token ColonColon "::"
159%token PeriodPeriod ".."
160@end
161
162@begin E4X ObjectiveC
163%token At "@"
164%token Pound "#"
165@end
166
167%token Ampersand "&"
168%token AmpersandAmpersand "&&"
169%token AmpersandEqual "&="
170%token Carrot "^"
171%token CarrotEqual "^="
172%token Equal "="
173%token EqualEqual "=="
174%token EqualEqualEqual "==="
175%token EqualRight "=>"
176%token EqualRight_ "\n=>"
177%token Exclamation "!"
178%token ExclamationEqual "!="
179%token ExclamationEqualEqual "!=="
180%token Hyphen "-"
181%token HyphenEqual "-="
182%token HyphenHyphen "--"
183%token HyphenHyphen_ "\n--"
184%token HyphenRight "->"
185%token Left "<"
186%token LeftEqual "<="
187%token LeftLeft "<<"
188%token LeftLeftEqual "<<="
189%token Percent "%"
190%token PercentEqual "%="
191%token Period "."
192%token PeriodPeriodPeriod "..."
193%token Pipe "|"
194%token PipeEqual "|="
195%token PipePipe "||"
196%token Plus "+"
197%token PlusEqual "+="
198%token PlusPlus "++"
199%token PlusPlus_ "\n++"
200%token Right ">"
201%token RightEqual ">="
202%token RightRight ">>"
203%token RightRightEqual ">>="
204%token RightRightRight ">>>"
205%token RightRightRightEqual ">>>="
206%token Slash "/"
207%token SlashEqual "/="
208%token Star "*"
209%token StarEqual "*="
210%token Tilde "~"
211
212%token Colon ":"
213%token Comma ","
214%token Question "?"
215%token SemiColon ";"
216%token NewLine "\n"
217
218%token <comment_> Comment
219
220%token OpenParen "("
221%token CloseParen ")"
222
223%token OpenBrace "{"
224%token OpenBrace_ "\n{"
225%token OpenBrace__ ";{"
226%token CloseBrace "}"
227
228%token OpenBracket "["
229%token CloseBracket "]"
230
231%token AtError "@error"
232
233@begin Java
234%token AtClass "@class"
235@end
236
237@begin C
238%token <identifier_> Typedef "typedef"
239%token <identifier_> Unsigned "unsigned"
240%token <identifier_> Signed "signed"
241%token <identifier_> Extern "extern"
242@end
243
244@begin C
245%token AtEncode "@encode"
246@end
247
248@begin ObjectiveC
249%token AtImplementation "@implementation"
250%token AtImplementation_ ";@implementation"
251%token AtImport "@import"
252%token AtEnd "@end"
253%token AtSelector "@selector"
254%token AtNull "@null"
255%token AtYes "@YES"
256%token AtNo "@NO"
257%token AtTrue "@true"
258%token AtFalse "@false"
259%token <identifier_> Yes "YES"
260%token <identifier_> No "NO"
261@end
262
263%token <false_> False "false"
264%token <null_> Null "null"
265%token <true_> True "true"
266
267// ES3/ES5/WIE/JSC Reserved
268%token <word_> Auto "auto"
269%token <word_> Break "break"
270%token <word_> Case "case"
271%token <word_> Catch "catch"
272%token <word_> Continue "continue"
273%token <word_> Default "default"
274%token <word_> Delete "delete"
275%token <word_> Do "do"
276%token <word_> Else "else"
277%token <word_> Finally "finally"
278%token <word_> For "for"
279%token <word_> Function "function"
280%token <word_> Function_ ";function"
281%token <word_> If "if"
282%token <word_> In "in"
283%token <word_> In_ "!in"
284%token <word_> InstanceOf "instanceof"
285%token <word_> New "new"
286%token <word_> Return "return"
287%token <word_> Switch "switch"
288%token <this_> This "this"
289%token <word_> Throw "throw"
290%token <word_> Try "try"
291%token <word_> TypeOf "typeof"
292%token <word_> Var "var"
293%token <word_> Void "void"
294%token <word_> While "while"
295%token <word_> With "with"
296
297// ES3/IE6 Future, ES5/JSC Reserved
298%token <word_> Debugger "debugger"
299
300// ES3/ES5/IE6 Future, JSC Reserved
301%token <word_> Const "const"
302
303// ES3/ES5/IE6/JSC Future
304%token <word_> Class "class"
305%token <word_> Enum "enum"
306%token <word_> Export "export"
307%token <word_> Extends "extends"
308%token <word_> Import "import"
309%token <word_> Super "super"
310
311// ES3 Future, ES5 Strict Future
312%token <identifier_> Implements "implements"
313%token <identifier_> Interface "interface"
314%token <identifier_> Package "package"
315%token <identifier_> Private "private"
316%token <identifier_> Protected "protected"
317%token <identifier_> Public "public"
318%token <identifier_> Static "static"
319
320// ES3 Future
321%token <identifier_> Abstract "abstract"
322%token <identifier_> Boolean "boolean"
323%token <identifier_> Byte "byte"
324%token <identifier_> Char "char"
325%token <identifier_> Double "double"
326%token <identifier_> Final "final"
327%token <identifier_> Float "float"
328%token <identifier_> Goto "goto"
329%token <identifier_> Int "int"
330%token <identifier_> Long "long"
331%token <identifier_> Native "native"
332%token <identifier_> Short "short"
333%token <identifier_> Synchronized "synchronized"
334%token <identifier_> Throws "throws"
335%token <identifier_> Transient "transient"
336%token <identifier_> Volatile "volatile"
337
338// ES5 Strict
339%token <identifier_> Let "let"
340%token <identifier_> Yield "yield"
341
342// Woah?!
343%token <identifier_> Each "each"
344%token <identifier_> Of "of"
345
346@begin E4X
347// E4X Conditional
348%token <identifier_> Namespace "namespace"
349%token <identifier_> XML "xml"
350@end
351
352%token AutoComplete
353
354%token <identifier_> Identifier_
355%token <number_> NumericLiteral
356%token <string_> StringLiteral
357%token <literal_> RegularExpressionLiteral
358
359%type <expression_> AdditiveExpression
360%type <argument_> ArgumentList_
361%type <argument_> ArgumentList
362%type <argument_> ArgumentListOpt
363%type <argument_> Arguments
364%type <expression_> ArrayComprehension
365%type <expression_> ArrayInitialiser
366%type <literal_> ArrayLiteral
367%type <expression_> ArrowFunction
368%type <functionParameter_> ArrowParameters
369%type <expression_> AssignmentExpression
370%type <identifier_> Binding
371%type <identifier_> BindingIdentifier
372%type <expression_> BitwiseANDExpression
373%type <statement_> Block_
374%type <statement_> Block
375%type <boolean_> BooleanLiteral
376%type <declaration_> BindingElement
377%type <expression_> BitwiseORExpression
378%type <expression_> BitwiseXORExpression
379%type <statement_> BreakStatement
380%type <statement_> BreakableStatement
381%type <expression_> CallExpression_
382%type <expression_> CallExpression
383%type <clause_> CaseBlock
384%type <clause_> CaseClause
385%type <clause_> CaseClausesOpt
386%type <catch_> CatchOpt
387%type <expression_> Comprehension
388%type <comprehension_> ComprehensionFor
389%type <comprehension_> ComprehensionIf
390%type <comprehension_> ComprehensionTail
391%type <expression_> ConditionalExpression
392%type <statement_> ContinueStatement
393%type <statement_> ConciseBody
394%type <statement_> DebuggerStatement
395%type <statement_> Declaration__
396%type <statement_> Declaration_
397%type <statement_> Declaration
398%type <clause_> DefaultClause
399%type <expression_> Element
400%type <expression_> ElementOpt
401%type <element_> ElementList
402%type <element_> ElementListOpt
403%type <statement_> ElseStatementOpt
404%type <statement_> EmptyStatement
405%type <expression_> EqualityExpression
406%type <expression_> Expression
407%type <expression_> ExpressionOpt
408%type <statement_> ExpressionStatement
409%type <finally_> FinallyOpt
410%type <for_> ForStatementInitialiser
411%type <forin_> ForInStatementInitialiser
412%type <declaration_> FormalParameter
413%type <functionParameter_> FormalParameterList_
414%type <functionParameter_> FormalParameterList
415%type <functionParameter_> FormalParameterListOpt
416%type <statement_> FunctionBody
417%type <statement_> FunctionDeclaration
418%type <expression_> FunctionExpression
419%type <identifier_> Identifier
420%type <identifier_> IdentifierOpt
421%type <identifier_> IdentifierType
422%type <word_> IdentifierName
423%type <statement_> IfStatement
424%type <expression_> Initialiser
425%type <expression_> InitialiserOpt
426%type <statement_> IterationStatement
427%type <statement_> LabelledStatement
428%type <expression_> LeftHandSideExpression
429%type <statement_> LetStatement
430%type <statement_> LexicalDeclaration
431%type <literal_> Literal
432%type <literal_> ValueLiteral
433%type <expression_> LogicalANDExpression
434%type <expression_> LogicalORExpression
435%type <member_> MemberAccess
436%type <expression_> MemberExpression_
437%type <expression_> MemberExpression
438%type <module_> Module
439%type <expression_> MultiplicativeExpression
440%type <expression_> NewExpression
441%type <null_> NullLiteral
442%type <literal_> ObjectLiteral
443%type <parenthetical_> Parenthetical
444%type <expression_> PostfixExpression
445%type <expression_> PrimaryExpression
446%type <statement_> Program
447%type <statement_> ProgramBody
448%type <statement_> ProgramBodyOpt
449%type <propertyName_> PropertyName_
450%type <propertyName_> PropertyName
451%type <property_> PropertyDefinition
452%type <property_> PropertyDefinitionList_
453%type <property_> PropertyDefinitionList
454%type <property_> PropertyDefinitionListOpt
455%type <expression_> RelationalExpression
456%type <statement_> ReturnStatement
457%type <rubyProc_> RubyProcExpression
458%type <functionParameter_> RubyProcParameterList_
459%type <functionParameter_> RubyProcParameterList
460%type <functionParameter_> RubyProcParameters
461%type <functionParameter_> RubyProcParametersOpt
462%type <expression_> ShiftExpression
463%type <declaration_> SingleNameBinding
464%type <statement_> Statement__
465%type <statement_> Statement_
466%type <statement_> Statement
467%type <statement_> StatementList
468%type <statement_> StatementListOpt
469%type <statement_> StatementListItem
470%type <statement_> SwitchStatement
471%type <statement_> ThrowStatement
472%type <statement_> TryStatement
473%type <expression_> UnaryExpression_
474%type <expression_> UnaryExpression
475%type <declaration_> VariableDeclaration
476%type <declarations_> VariableDeclarationList_
477%type <declarations_> VariableDeclarationList
478%type <statement_> VariableStatement
479%type <statement_> WithStatement
480%type <word_> Word
481@begin ObjectiveC
482%type <word_> WordOpt
483@end
484%type <expression_> Variable
485
486@begin C
487%type <specifier_> IntegerType
488%type <specifier_> IntegerTypeOpt
489%type <typedIdentifier_> PrefixedType
490%type <specifier_> PrimitiveType
491%type <typedIdentifier_> SuffixedType
492%type <typedIdentifier_> TypeSignifier
493%type <modifier_> TypeQualifierLeft
494%type <typedIdentifier_> TypeQualifierRight
495%type <typedIdentifier_> TypedIdentifier
496%type <typedParameter_> TypedParameterList_
497%type <typedParameter_> TypedParameterList
498%type <typedParameter_> TypedParameterListOpt
499@end
500
501@begin ObjectiveC
502%type <expression_> BoxableExpression
503%type <statement_> CategoryStatement
504%type <expression_> ClassExpression
505%type <classField_> ClassFieldListOpt
506%type <classField_> ClassFields
507%type <statement_> ClassStatement
508%type <expression_> ClassSuperOpt
509%type <message_> ClassMessageDeclaration
510%type <message_> ClassMessageDeclarationListOpt
511%type <className_> ClassName
512%type <className_> ClassNameOpt
513%type <protocol_> ClassProtocolListOpt
514%type <protocol_> ClassProtocols
515%type <protocol_> ClassProtocolsOpt
516%type <expression_> MessageExpression
517%type <messageParameter_> MessageParameter
518%type <messageParameter_> MessageParameters
519%type <messageParameter_> MessageParameterList
520%type <messageParameter_> MessageParameterListOpt
521%type <bool_> MessageScope
522%type <argument_> SelectorCall_
523%type <argument_> SelectorCall
524%type <selector_> SelectorExpression_
525%type <selector_> SelectorExpression
526%type <selector_> SelectorExpressionOpt
527%type <argument_> SelectorList
528%type <word_> SelectorWordOpt
529%type <typedIdentifier_> TypeOpt
530%type <argument_> VariadicCall
531@end
532
533@begin E4X
534%type <propertyIdentifier_> PropertyIdentifier_
535%type <selector_> PropertySelector_
536%type <selector_> PropertySelector
537%type <identifier_> QualifiedIdentifier_
538%type <identifier_> QualifiedIdentifier
539%type <identifier_> WildcardIdentifier
540%type <identifier_> XMLComment
541%type <identifier_> XMLCDATA
542%type <identifier_> XMLElement
543%type <identifier_> XMLElementContent
544%type <identifier_> XMLMarkup
545%type <identifier_> XMLPI
546
547%type <attribute_> AttributeIdentifier
548/* XXX: %type <statement_> DefaultXMLNamespaceStatement */
549%type <expression_> PropertyIdentifier
550%type <expression_> XMLListInitialiser
551%type <expression_> XMLInitialiser
552@end
553/* }}} */
554/* Token Priorities {{{ */
555%nonassoc ""
556%left "++" "--"
557
558%nonassoc "if"
559%nonassoc "else"
560/* }}} */
561
562%start Program
563
564%%
565
566/* Lexer State {{{ */
567LexPushInOn
568 : { driver.in_.push(true); }
569 ;
570
571LexPushInOff
572 : { driver.in_.push(false); }
573 ;
574
575LexPopIn
576 : { driver.in_.pop(); }
577 ;
578
579LexSetRegExp
580 : { driver.SetCondition(CYDriver::RegExpCondition); }
581 ;
582
583LexNoBrace
584 : { if (yyla.empty()) driver.no_.OpenBrace = true; else if (yyla.type == yytranslate_(token::OpenBrace) || yyla.type == yytranslate_(token::OpenBrace_)) yyla.type = yytranslate_(token::OpenBrace__); }
585 ;
586
587LexNoFunction
588 : { if (yyla.empty()) driver.no_.Function = true; else if (yyla.type == yytranslate_(token::Function)) yyla.type = yytranslate_(token::Function_); }
589 ;
590
591LexNoAtImplementation :
592@begin ObjectiveC
593 { if (yyla.empty()) driver.no_.AtImplementation = true; else if (yyla.type == yytranslate_(token::AtImplementation)) yyla.type = yytranslate_(token::AtImplementation_); }
594@end
595 ;
596
597LexSetStatement
598 : LexNoBrace LexNoFunction LexNoAtImplementation
599 ;
600/* }}} */
601/* Virtual Tokens {{{ */
602BRACE
603 : "{"
604 | "\n{"
605 ;
606
607Var_
608 : "var"
609 ;
610/* }}} */
611
612/* 7.6 Identifier Names and Identifiers {{{ */
613IdentifierName
614 : Word { $$ = $1; }
615 ;
616
617NewLineOpt
618 : "\n"
619 |
620 ;
621
622Word
623 : Identifier { $$ = $1; }
624 | "auto" { $$ = $1; }
625 | "break" NewLineOpt { $$ = $1; }
626 | "case" { $$ = $1; }
627 | "catch" { $$ = $1; }
628 | "class" { $$ = $1; }
629 | "const" { $$ = $1; }
630 | "continue" NewLineOpt { $$ = $1; }
631 | "debugger" { $$ = $1; }
632 | "default" { $$ = $1; }
633 | "delete" LexSetRegExp { $$ = $1; }
634 | "do" { $$ = $1; }
635 | "else" { $$ = $1; }
636 | "enum" { $$ = $1; }
637 | "export" { $$ = $1; }
638 | "extends" { $$ = $1; }
639 | "false" { $$ = $1; }
640 | "finally" { $$ = $1; }
641 /* XXX: | "for" { $$ = $1; } */
642 | "function" { $$ = $1; }
643 | "if" { $$ = $1; }
644 | "import" { $$ = $1; }
645 /* XXX: | "in" { $$ = $1; } */
646 | "!in" { $$ = $1; }
647 /* XXX: | "instanceof" { $$ = $1; } */
648
649 // XXX: as it currently is not an Identifier
650 | "let" { $$ = $1; }
651
652 | "new" LexSetRegExp { $$ = $1; }
653 | "null" { $$ = $1; }
654 | "return" NewLineOpt { $$ = $1; }
655 | "super" { $$ = $1; }
656 | "switch" { $$ = $1; }
657 | "this" { $$ = $1; }
658 | "throw" NewLineOpt { $$ = $1; }
659 | "true" { $$ = $1; }
660 | "try" { $$ = $1; }
661 | "typeof" LexSetRegExp { $$ = $1; }
662 | "var" { $$ = $1; }
663 | "void" LexSetRegExp { $$ = $1; }
664 | "while" { $$ = $1; }
665 | "with" { $$ = $1; }
666 ;
667
668@begin ObjectiveC
669WordOpt
670 : Word { $$ = $1; }
671 | { $$ = NULL; }
672 ;
673@end
674
675IdentifierType
676 : Identifier_ { $$ = $1; }
677
678 | "implements" { $$ = $1; }
679 | "interface" { $$ = $1; }
680 | "package" { $$ = $1; }
681 | "private" { $$ = $1; }
682 | "protected" { $$ = $1; }
683 | "public" { $$ = $1; }
684 | "static" { $$ = $1; }
685
686 | "abstract" { $$ = $1; }
687 | "boolean" { $$ = $1; }
688 | "byte" { $$ = $1; }
689 | "double" { $$ = $1; }
690 | "final" { $$ = $1; }
691 | "float" { $$ = $1; }
692 | "goto" { $$ = $1; }
693 | "native" { $$ = $1; }
694 | "synchronized" { $$ = $1; }
695 | "throws" { $$ = $1; }
696 | "transient" { $$ = $1; }
697
698 // XXX: currently I only have this as Word
699 // | "let" { $$ = $1; }
700
701 | "yield" NewLineOpt { $$ = $1; }
702
703 | "each" { $$ = $1; }
704 | "of" { $$ = $1; }
705 ;
706
707Identifier
708 : IdentifierType
709 | "char" { $$ = $1; }
710 | "int" { $$ = $1; }
711 | "long" { $$ = $1; }
712 | "short" { $$ = $1; }
713 | "volatile" { $$ = $1; }
714@begin C
715 | "typedef" { $$ = $1; }
716 | "unsigned" { $$ = $1; }
717 | "signed" { $$ = $1; }
718 | "extern" { $$ = $1; }
719@end
720@begin ObjectiveC
721 | "YES" { $$ = $1; }
722 | "NO" { $$ = $1; }
723@end
724 ;
725
726IdentifierOpt
727 : Identifier { $$ = $1; }
728 | { $$ = NULL; }
729 ;
730/* }}} */
731
732/* 7.8 Literals {{{ */
733Literal
734 : NullLiteral { $$ = $1; }
735 | ValueLiteral { $$ = $1; }
736 ;
737
738ValueLiteral
739 : BooleanLiteral { $$ = $1; }
740 | NumericLiteral { $$ = $1; }
741 | StringLiteral { $$ = $1; }
742 | RegularExpressionLiteral { $$ = $1; }
743 ;
744/* }}} */
745/* 7.8.1 Null Literals {{{ */
746NullLiteral
747 : "null" { $$ = $1; }
748 ;
749/* }}} */
750/* 7.8.2 Boolean Literals {{{ */
751BooleanLiteral
752 : "true" { $$ = $1; }
753 | "false" { $$ = $1; }
754 ;
755/* }}} */
756
757/* 7.9 Automatic Semicolon Insertion {{{ */
758StrictSemi
759 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
760 ;
761
762Terminator
763 : ";"
764 | error { if (yyla.type_get() != yyeof_ && yyla.type != yytranslate_(token::CloseBrace) && !yyla.value.newline_) { error(@1, "required semi-colon"); } else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
765 ;
766
767TerminatorOpt
768 : ";"
769 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
770 ;
771/* }}} */
772
773/* 11.1 Primary Expressions {{{ */
774Parenthetical
775 : "(" LexPushInOff Expression ")" LexPopIn { $$ = CYNew CYParenthetical($3); }
776 ;
777
778Variable
779 : Identifier { $$ = CYNew CYVariable($1); }
780 ;
781
782PrimaryExpression
783 : "this" { $$ = $1; }
784 | Variable { $$ = $1; }
785 | Literal { $$ = $1; }
786 | ArrayInitialiser { $$ = $1; }
787 | ObjectLiteral { $$ = $1; }
788 | Parenthetical { $$ = $1; }
789 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
790 ;
791/* }}} */
792/* 11.1.4 Array Initializer {{{ */
793ArrayInitialiser
794 : ArrayLiteral { $$ = $1; }
795 | ArrayComprehension { $$ = $1; }
796 ;
797/* }}} */
798/* 11.1.4.1 Array Literal {{{ */
799ArrayLiteral
800 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
801 ;
802
803Element
804 : AssignmentExpression { $$ = $1; }
805 ;
806
807ElementOpt
808 : Element { $$ = $1; }
809 | LexSetRegExp { $$ = NULL; }
810 ;
811
812ElementList
813 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
814 | Element { $$ = CYNew CYElement($1, NULL); }
815 ;
816
817ElementListOpt
818 : ElementList { $$ = $1; }
819 | LexSetRegExp { $$ = NULL; }
820 ;
821/* }}} */
822/* 11.1.4.2 Array Comprehension {{{ */
823ArrayComprehension
824 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
825 ;
826
827Comprehension
828 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
829 ;
830
831ComprehensionTail
832 : { $$ = NULL; }
833 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
834 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
835 ;
836
837ComprehensionFor
838 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
839 ;
840
841ComprehensionIf
842 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
843 ;
844/* }}} */
845/* 11.1.5 Object Initialiser {{{ */
846ObjectLiteral
847 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
848 ;
849
850PropertyDefinitionList_
851 : "," PropertyDefinitionList { $$ = $2; }
852 | "," LexSetRegExp { $$ = NULL; }
853 | { $$ = NULL; }
854 ;
855
856PropertyDefinitionList
857 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
858 ;
859
860PropertyDefinitionListOpt
861 : PropertyDefinitionList { $$ = $1; }
862 | LexSetRegExp { $$ = NULL; }
863 ;
864
865PropertyDefinition
866 // XXX: this should be IdentifierName
867 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
868 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
869 //| MethodDefinition
870 ;
871
872PropertyName_
873 : IdentifierName { $$ = $1; }
874 | StringLiteral { $$ = $1; }
875 | NumericLiteral { $$ = $1; }
876 ;
877
878PropertyName
879 : LexSetRegExp PropertyName_ { $$ = $2; }
880 ;
881/* }}} */
882
883/* 11.2 Left-Hand-Side Expressions {{{ */
884MemberAccess
885 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
886 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
887 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
888 ;
889
890MemberExpression_
891 : MemberExpression { $$ = $1; }
892 //| "super" { $$ = $1; }
893 ;
894
895MemberExpression
896 : LexSetRegExp PrimaryExpression { $$ = $2; }
897 | LexSetRegExp FunctionExpression { $$ = $2; }
898 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
899 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
900 ;
901
902NewExpression
903 : MemberExpression { $$ = $1; }
904 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
905 ;
906
907CallExpression_
908 : MemberExpression_
909 | CallExpression
910 ;
911
912CallExpression
913 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
914 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
915 ;
916
917Arguments
918 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
919 ;
920
921ArgumentList_
922 : "," ArgumentList { $$ = $2; }
923 | { $$ = NULL; }
924 ;
925
926ArgumentList
927 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
928 | LexSetRegExp Word ":" AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument($2, $4, $5); }
929 ;
930
931ArgumentListOpt
932 : ArgumentList { $$ = $1; }
933 | LexSetRegExp { $$ = NULL; }
934 ;
935
936LeftHandSideExpression
937 : NewExpression { $$ = $1; }
938 | CallExpression { $$ = $1; }
939 ;
940/* }}} */
941/* 11.3 Postfix Expressions {{{ */
942PostfixExpression
943 : %prec "" LeftHandSideExpression { $$ = $1; }
944 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
945 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
946 ;
947/* }}} */
948/* 11.4 Unary Operators {{{ */
949UnaryExpression_
950 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
951 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
952 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
953 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
954 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
955 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
956 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
957 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
958 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
959 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
960 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
961 ;
962
963UnaryExpression
964 : PostfixExpression { $$ = $1; }
965 | LexSetRegExp UnaryExpression_ { $$ = $2; }
966 ;
967/* }}} */
968/* 11.5 Multiplicative Operators {{{ */
969MultiplicativeExpression
970 : UnaryExpression { $$ = $1; }
971 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
972 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
973 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
974 ;
975/* }}} */
976/* 11.6 Additive Operators {{{ */
977AdditiveExpression
978 : MultiplicativeExpression { $$ = $1; }
979 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
980 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
981 ;
982/* }}} */
983/* 11.7 Bitwise Shift Operators {{{ */
984ShiftExpression
985 : AdditiveExpression { $$ = $1; }
986 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
987 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
988 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
989 ;
990/* }}} */
991/* 11.8 Relational Operators {{{ */
992RelationalExpression
993 : ShiftExpression { $$ = $1; }
994 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
995 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
996 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
997 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
998 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
999 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1000 ;
1001/* }}} */
1002/* 11.9 Equality Operators {{{ */
1003EqualityExpression
1004 : RelationalExpression { $$ = $1; }
1005 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1006 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1007 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1008 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1009 ;
1010/* }}} */
1011/* 11.10 Binary Bitwise Operators {{{ */
1012BitwiseANDExpression
1013 : EqualityExpression { $$ = $1; }
1014 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1015 ;
1016
1017BitwiseXORExpression
1018 : BitwiseANDExpression { $$ = $1; }
1019 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1020 ;
1021
1022BitwiseORExpression
1023 : BitwiseXORExpression { $$ = $1; }
1024 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1025 ;
1026/* }}} */
1027/* 11.11 Binary Logical Operators {{{ */
1028LogicalANDExpression
1029 : BitwiseORExpression { $$ = $1; }
1030 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1031 ;
1032
1033LogicalORExpression
1034 : LogicalANDExpression { $$ = $1; }
1035 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1036 ;
1037/* }}} */
1038/* 11.12 Conditional Operator ( ? : ) {{{ */
1039ConditionalExpression
1040 : LogicalORExpression { $$ = $1; }
1041 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1042 | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1043 ;
1044/* }}} */
1045/* 11.13 Assignment Operators {{{ */
1046AssignmentExpression
1047 : ConditionalExpression { $$ = $1; }
1048 | ArrowFunction { $$ = $1; }
1049 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1050 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1051 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1052 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1053 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1054 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1055 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1056 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1057 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1058 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1059 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1060 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1061 ;
1062/* }}} */
1063/* 11.14 Comma Operator {{{ */
1064Expression
1065 : AssignmentExpression { $$ = $1; }
1066 | AssignmentExpression "," Expression { $$ = CYNew CYCompound($1, $3); }
1067 ;
1068
1069ExpressionOpt
1070 : Expression { $$ = $1; }
1071 | LexSetRegExp { $$ = NULL; }
1072 ;
1073/* }}} */
1074
1075/* 12 Statements {{{ */
1076Statement__
1077 : Block { $$ = $1; }
1078 | VariableStatement { $$ = $1; }
1079 | EmptyStatement { $$ = $1; }
1080 | IfStatement { $$ = $1; }
1081 | BreakableStatement { $$ = $1; }
1082 | ContinueStatement { $$ = $1; }
1083 | BreakStatement { $$ = $1; }
1084 | ReturnStatement { $$ = $1; }
1085 | WithStatement { $$ = $1; }
1086 | LabelledStatement { $$ = $1; }
1087 | ThrowStatement { $$ = $1; }
1088 | TryStatement { $$ = $1; }
1089 | DebuggerStatement { $$ = $1; }
1090 ;
1091
1092Statement_
1093 : LexSetRegExp Statement__ { $$ = $2; }
1094 | ExpressionStatement { $$ = $1; }
1095 ;
1096
1097Statement
1098 : LexSetStatement Statement_ { $$ = $2; }
1099 ;
1100
1101Declaration__
1102 : FunctionDeclaration { $$ = $1; }
1103 | LexicalDeclaration { $$ = $1; }
1104 ;
1105
1106Declaration_
1107 : LexSetRegExp Declaration__ { $$ = $2; }
1108 ;
1109
1110Declaration
1111 : LexSetStatement Declaration_ { $$ = $2; }
1112 ;
1113
1114BreakableStatement
1115 : IterationStatement { $$ = $1; }
1116 | SwitchStatement { $$ = $1; }
1117 ;
1118/* }}} */
1119/* 12.1 Block {{{ */
1120Block_
1121 : BRACE StatementListOpt "}" { $$ = $2; }
1122 ;
1123
1124Block
1125 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1126 ;
1127
1128StatementList
1129 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1130 ;
1131
1132StatementListOpt
1133 : StatementList { $$ = $1; }
1134 | LexSetStatement LexSetRegExp { $$ = NULL; }
1135 ;
1136
1137StatementListItem
1138 : Statement { $$ = $1; }
1139 | Declaration { $$ = $1; }
1140 ;
1141/* }}} */
1142
1143/* 12.2 Declarations {{{ */
1144BindingIdentifier
1145 : Identifier { $$ = $1; }
1146 ;
1147
1148Binding
1149 : BindingIdentifier
1150 ;
1151
1152// XXX: BindingPattern
1153/* }}} */
1154/* 12.2.1 Let and Const Declarations {{{ */
1155LexicalDeclaration
1156 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1157 ;
1158
1159LetOrConst
1160 : "let"
1161 | "const"
1162 ;
1163/* }}} */
1164/* 12.2.2 Variable Statement {{{ */
1165VariableStatement
1166 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1167 ;
1168
1169VariableDeclarationList_
1170 : "," VariableDeclarationList { $$ = $2; }
1171 | { $$ = NULL; }
1172 ;
1173
1174VariableDeclarationList
1175 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1176 ;
1177
1178VariableDeclaration
1179 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1180 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1181 ;
1182
1183Initialiser
1184 : "=" AssignmentExpression { $$ = $2; }
1185 ;
1186
1187InitialiserOpt
1188 : Initialiser { $$ = $1; }
1189 | { $$ = NULL; }
1190 ;
1191/* }}} */
1192/* 12.2.4 Destructuring Binding Patterns {{{ */
1193// XXX: *
1194
1195BindingElement
1196 : SingleNameBinding { $$ = $1; }
1197 ;
1198
1199SingleNameBinding
1200 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1201 ;
1202/* }}} */
1203
1204/* 12.3 Empty Statement {{{ */
1205EmptyStatement
1206 : ";" { $$ = CYNew CYEmpty(); }
1207 ;
1208/* }}} */
1209/* 12.4 Expression Statement {{{ */
1210ExpressionStatement
1211 : Expression Terminator { $$ = CYNew CYExpress($1); }
1212 ;
1213/* }}} */
1214/* 12.5 The if Statement {{{ */
1215ElseStatementOpt
1216 : "else" Statement { $$ = $2; }
1217 | %prec "if" { $$ = NULL; }
1218 ;
1219
1220IfStatement
1221 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1222 ;
1223/* }}} */
1224
1225/* 12.6.1 The do-while Statement {{{ */
1226IterationStatement
1227 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1228 ;
1229/* }}} */
1230/* 12.6.2 The while Statement {{{ */
1231IterationStatement
1232 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1233 ;
1234/* }}} */
1235/* 12.6.3 The for Statement {{{ */
1236IterationStatement
1237 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1238 ;
1239
1240ForStatementInitialiser
1241 : ExpressionOpt { $$ = $1; }
1242 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1243 ;
1244/* }}} */
1245/* 12.6.4 The for-in and for-of Statements {{{ */
1246IterationStatement
1247 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1248 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1249 ;
1250
1251ForInStatementInitialiser
1252 : LeftHandSideExpression { $$ = $1; }
1253 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1254 ;
1255/* }}} */
1256
1257/* 12.7 The continue Statement {{{ */
1258ContinueStatement
1259 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1260 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1261 ;
1262/* }}} */
1263/* 12.8 The break Statement {{{ */
1264BreakStatement
1265 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1266 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1267 ;
1268/* }}} */
1269/* 12.9 The return Statement {{{ */
1270ReturnStatement
1271 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1272 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1273 ;
1274/* }}} */
1275/* 12.10 The with Statement {{{ */
1276WithStatement
1277 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1278 ;
1279/* }}} */
1280
1281/* 12.11 The switch Statement {{{ */
1282SwitchStatement
1283 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1284 ;
1285
1286CaseBlock
1287 : BRACE CaseClausesOpt "}" { $$ = $2; }
1288 ;
1289
1290CaseClause
1291 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1292 ;
1293
1294CaseClausesOpt
1295 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1296 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1297 | { $$ = NULL; }
1298 ;
1299
1300DefaultClause
1301 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1302 ;
1303/* }}} */
1304/* 12.12 Labelled Statements {{{ */
1305LabelledStatement
1306 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1307 ;
1308/* }}} */
1309/* 12.13 The throw Statement {{{ */
1310ThrowStatement
1311 : "throw" LexSetRegExp "\n" StrictSemi { error(@1, "throw without exception"); }
1312 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1313 ;
1314/* }}} */
1315/* 12.14 The try Statement {{{ */
1316TryStatement
1317 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1318 ;
1319
1320CatchOpt
1321 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1322 | { $$ = NULL; }
1323 ;
1324
1325FinallyOpt
1326 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1327 | { $$ = NULL; }
1328 ;
1329/* }}} */
1330/* 12.14 The debugger Statement {{{ */
1331DebuggerStatement
1332 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1333 ;
1334/* }}} */
1335
1336/* 13.1 Function Definitions {{{ */
1337FunctionDeclaration
1338 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1339 ;
1340
1341FunctionExpression
1342 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1343 ;
1344
1345FormalParameterList_
1346 : "," FormalParameterList { $$ = $2; }
1347 | { $$ = NULL; }
1348 ;
1349
1350FormalParameterList
1351 // XXX: : FunctionRestParameter { $$ = $1; }
1352 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1353 ;
1354
1355FormalParameterListOpt
1356 : FormalParameterList
1357 | { $$ = NULL; }
1358 ;
1359
1360/* XXX: FunctionRestParameter
1361 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1362 ;*/
1363
1364FormalParameter
1365 : BindingElement { $$ = $1; }
1366 ;
1367
1368FunctionBody
1369 : StatementListOpt { $$ = $1; }
1370 ;
1371/* }}} */
1372/* 13.2 Arrow Function Definitions {{{ */
1373ArrowFunction
1374 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1375 ;
1376
1377ArrowParameters
1378 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1379 | "(" LexPushInOff LexSetRegExp ")" LexPopIn { $$ = NULL; }
1380 | Parenthetical { $$ = $1->expression_->Parameter(); if ($$ == NULL) error(@1, "invalid parameter list"); }
1381 ;
1382
1383ConciseBody
1384 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1385 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1386 ;
1387/* }}} */
1388/* 14 Program {{{ */
1389Program
1390 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1391 ;
1392
1393ProgramBody
1394 : StatementList { $$ = $1; }
1395 ;
1396
1397ProgramBodyOpt
1398 : ProgramBody { $$ = $1; }
1399 | LexSetStatement LexSetRegExp { $$ = NULL; }
1400 ;
1401/* }}} */
1402
1403@begin C
1404/* Cycript (C): Type Encoding {{{ */
1405TypeSignifier
1406 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1407 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1408 ;
1409
1410SuffixedType
1411 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1412 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1413 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1414 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1415 | TypeSignifier { $$ = $1; }
1416 | { $$ = CYNew CYTypedIdentifier(@$); }
1417 ;
1418
1419PrefixedType
1420 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1421 ;
1422
1423TypeQualifierLeft
1424 : { $$ = NULL; }
1425 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1426 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1427 ;
1428
1429TypeQualifierRight
1430 : PrefixedType { $$ = $1; }
1431 | SuffixedType { $$ = $1; }
1432 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1433 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1434 ;
1435
1436IntegerType
1437 : "int" { $$ = CYNew CYTypeVariable("int"); }
1438 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1439 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1440 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1441 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1442 ;
1443
1444IntegerTypeOpt
1445 : IntegerType { $$ = $1; }
1446 | { $$ = CYNew CYTypeVariable("int"); }
1447 ;
1448
1449PrimitiveType
1450 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1451 | IntegerType { $$ = $1; }
1452 | "void" { $$ = CYNew CYTypeVoid(); }
1453 | "char" { $$ = CYNew CYTypeVariable("char"); }
1454 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1455 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1456 ;
1457
1458TypedIdentifier
1459 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1460 ;
1461
1462PrimaryExpression
1463 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1464 ;
1465/* }}} */
1466@end
1467
1468@begin ObjectiveC
1469/* Cycript (Objective-C): @class Declaration {{{ */
1470ClassSuperOpt
1471 /* XXX: why the hell did I choose MemberExpression? */
1472 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1473 | { $$ = NULL; }
1474 ;
1475
1476ClassFieldListOpt
1477 : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYClassField($1, $3); }
1478 | LexSetRegExp { $$ = NULL; }
1479 ;
1480
1481ClassFields
1482 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1483 ;
1484
1485MessageScope
1486 : "+" { $$ = false; }
1487 | "-" { $$ = true; }
1488 ;
1489
1490TypeOpt
1491 : "(" LexSetRegExp TypedIdentifier ")" { if ($3->identifier_ != NULL) error($3->location_, "unexpected identifier"); $$ = $3; }
1492 | { $$ = CYNew CYTypedIdentifier(CYNew CYTypeVariable("id")); }
1493 ;
1494
1495MessageParameter
1496 : Word ":" TypeOpt Identifier { $3->identifier_ = $4; $$ = CYNew CYMessageParameter($1, $3); }
1497 ;
1498
1499MessageParameterList
1500 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1501 ;
1502
1503MessageParameterListOpt
1504 : MessageParameterList { $$ = $1; }
1505 | { $$ = NULL; }
1506 ;
1507
1508MessageParameters
1509 : MessageParameterList { $$ = $1; }
1510 | Word { $$ = CYNew CYMessageParameter($1, NULL); }
1511 ;
1512
1513ClassMessageDeclaration
1514 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1515 ;
1516
1517ClassMessageDeclarationListOpt
1518 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1519 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1520 | { $$ = NULL; }
1521 ;
1522
1523ClassName
1524 : Identifier { $$ = $1; }
1525 | "(" AssignmentExpression ")" { $$ = $2; }
1526 ;
1527
1528ClassNameOpt
1529 : ClassName { $$ = $1; }
1530 | { $$ = NULL; }
1531 ;
1532
1533// XXX: this should be AssignmentExpressionNoRight
1534ClassProtocols
1535 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1536 ;
1537
1538ClassProtocolsOpt
1539 : "," ClassProtocols { $$ = $2; }
1540 | { $$ = NULL; }
1541 ;
1542
1543ClassProtocolListOpt
1544 : "<" ClassProtocols ">" { $$ = $2; }
1545 | { $$ = NULL; }
1546 ;
1547
1548ClassExpression
1549 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1550 ;
1551
1552ClassStatement
1553 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1554 ;
1555
1556CategoryName
1557 : "(" WordOpt ")"
1558 ;
1559
1560CategoryStatement
1561 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1562 ;
1563
1564PrimaryExpression
1565 : ClassExpression { $$ = $1; }
1566 ;
1567
1568Statement__
1569 : ClassStatement { $$ = $1; }
1570 | CategoryStatement { $$ = $1; }
1571 ;
1572/* }}} */
1573/* Cycript (Objective-C): Send Message {{{ */
1574VariadicCall
1575 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1576 | { $$ = NULL; }
1577 ;
1578
1579SelectorWordOpt
1580 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1581 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1582 ;
1583
1584SelectorCall_
1585 : SelectorCall { $$ = $1; }
1586 | VariadicCall { $$ = $1; }
1587 ;
1588
1589SelectorCall
1590 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1591 ;
1592
1593SelectorList
1594 : SelectorCall { $$ = $1; }
1595 | Word { $$ = CYNew CYArgument($1, NULL); }
1596 ;
1597
1598MessageExpression
1599 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1600 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1601 ;
1602
1603SelectorExpression_
1604 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1605 ;
1606
1607SelectorExpression
1608 : SelectorExpression_ { $$ = $1; }
1609 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1610 ;
1611
1612SelectorExpressionOpt
1613 : SelectorExpression_ { $$ = $1; }
1614 | { $$ = NULL; }
1615 ;
1616
1617PrimaryExpression
1618 : MessageExpression { $$ = $1; }
1619 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1620 ;
1621/* }}} */
1622@end
1623
1624/* Cycript: @import Directive {{{ */
1625Module
1626 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1627 | Word { $$ = CYNew CYModule($1); }
1628 ;
1629
1630Declaration__
1631 : "@import" Module { $$ = CYNew CYImport($2); }
1632 ;
1633/* }}} */
1634
1635@begin ObjectiveC
1636/* Cycript (Objective-C): Boxed Expressions {{{ */
1637BoxableExpression
1638 : NullLiteral { $$ = $1; }
1639 | BooleanLiteral { $$ = $1; }
1640 | NumericLiteral { $$ = $1; }
1641 | StringLiteral { $$ = $1; }
1642 | ArrayLiteral { $$ = $1; }
1643 | ObjectLiteral { $$ = $1; }
1644 | Parenthetical { $$ = $1; }
1645 | "YES" { $$ = CYNew CYTrue(); }
1646 | "NO" { $$ = CYNew CYFalse(); }
1647 ;
1648
1649PrimaryExpression
1650 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1651 | "@YES" { $$ = CYNew CYBox(CYNew CYTrue()); }
1652 | "@NO" { $$ = CYNew CYBox(CYNew CYFalse()); }
1653 | "@true" { $$ = CYNew CYBox(CYNew CYTrue()); }
1654 | "@false" { $$ = CYNew CYBox(CYNew CYFalse()); }
1655 | "@null" { $$ = CYNew CYBox(CYNew CYNull()); }
1656 ;
1657/* }}} */
1658/* Cycript (Objective-C): Block Expressions {{{ */
1659PrimaryExpression
1660 : "^" TypedIdentifier { if ($2->identifier_ != NULL) error($2->location_, "unexpected identifier"); } BRACE LexPushInOff FunctionBody "}" LexPopIn { if (CYTypeFunctionWith *function = $2->Function()) $$ = CYNew CYObjCBlock($2, function->parameters_, $6); else error($2->location_, "expected parameters"); }
1661 ;
1662/* }}} */
1663/* Cycript (Objective-C): Instance Literals {{{ */
1664PrimaryExpression
1665 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
1666 ;
1667/* }}} */
1668@end
1669
1670@begin C
1671/* Cycript (C): Pointer Indirection/Addressing {{{ */
1672LeftHandSideExpression
1673 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1674 ;
1675
1676UnaryExpression_
1677 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1678 ;
1679
1680MemberAccess
1681 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1682 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1683 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1684 ;
1685/* }}} */
1686/* Cycript (C): auto Compatibility {{{ */
1687Var_
1688 : "auto"
1689 ;
1690/* }}} */
1691/* Cycript (C): Lambda Expressions {{{ */
1692TypedParameterList_
1693 : "," TypedParameterList { $$ = $2; }
1694 | { $$ = NULL; }
1695 ;
1696
1697TypedParameterList
1698 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1699 ;
1700
1701TypedParameterListOpt
1702 : TypedParameterList { $$ = $1; }
1703 | { $$ = NULL; }
1704 ;
1705
1706PrimaryExpression
1707 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1708 ;
1709/* }}} */
1710/* Cycript (C): Type Definitions {{{ */
1711Statement__
1712 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) error($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
1713 ;
1714/* }}} */
1715/* Cycript (C): extern "C" {{{ */
1716Statement__
1717 : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) error(@2, "unknown extern binding"); } TypedIdentifier { if ($4->identifier_ == NULL) error($4->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($2, $4); }
1718 ;
1719/* }}} */
1720
1721@end
1722
1723/* YUI: Documentation Comments {{{ */
1724Statement__
1725 : Comment { $$ = $1; }
1726 ;
1727/* }}} */
1728
1729@begin E4X
1730/* Lexer State {{{ */
1731LexPushRegExp
1732 : { driver.PushCondition(CYDriver::RegExpCondition); }
1733 ;
1734
1735LexPushXMLContent
1736 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1737 ;
1738
1739LexPushXMLTag
1740 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1741 ;
1742
1743LexPop
1744 : { driver.PopCondition(); }
1745 ;
1746
1747LexSetXMLContent
1748 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1749 ;
1750
1751LexSetXMLTag
1752 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1753 ;
1754/* }}} */
1755/* Virtual Tokens {{{ */
1756XMLWhitespaceOpt
1757 : XMLWhitespace
1758 |
1759 ;
1760/* }}} */
1761
1762/* 8.1 Context Keywords {{{ */
1763Identifier
1764 : "namespace" { $$ = $1; }
1765 | "xml" { $$ = $1; }
1766 ;
1767/* }}} */
1768/* 8.3 XML Initialiser Input Elements {{{ */
1769XMLMarkup
1770 : XMLComment { $$ = $1; }
1771 | XMLCDATA { $$ = $1; }
1772 | XMLPI { $$ = $1; }
1773 ;
1774/* }}} */
1775
1776/* 11.1 Primary Expressions {{{ */
1777PrimaryExpression
1778 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1779 | XMLInitialiser { $$ = $1; }
1780 | XMLListInitialiser { $$ = $1; }
1781 ;
1782
1783PropertyIdentifier
1784 : AttributeIdentifier { $$ = $1; }
1785 | QualifiedIdentifier { $$ = $1; }
1786 | WildcardIdentifier { $$ = $1; }
1787 ;
1788/* }}} */
1789/* 11.1.1 Attribute Identifiers {{{ */
1790AttributeIdentifier
1791 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1792 ;
1793
1794PropertySelector_
1795 : PropertySelector { $$ = $1; }
1796 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1797 ;
1798
1799PropertySelector
1800 : Identifier { $$ = CYNew CYSelector($1); }
1801 | WildcardIdentifier { $$ = $1; }
1802 ;
1803/* }}} */
1804/* 11.1.2 Qualified Identifiers {{{ */
1805QualifiedIdentifier_
1806 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1807 | QualifiedIdentifier { $$ = $1; }
1808 ;
1809
1810QualifiedIdentifier
1811 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1812 ;
1813/* }}} */
1814/* 11.1.3 Wildcard Identifiers {{{ */
1815WildcardIdentifier
1816 : "*" { $$ = CYNew CYWildcard(); }
1817 ;
1818/* }}} */
1819/* 11.1.4 XML Initialiser {{{ */
1820XMLInitialiser
1821 : XMLMarkup { $$ = $1; }
1822 | XMLElement { $$ = $1; }
1823 ;
1824
1825XMLElement
1826 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1827 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1828 ;
1829
1830XMLTagContent
1831 : LexPushXMLTag XMLTagName XMLAttributes
1832 ;
1833
1834XMLExpression
1835 : BRACE LexPushRegExp Expression LexPop "}"
1836 ;
1837
1838XMLTagName
1839 : XMLExpression
1840 | XMLName
1841 ;
1842
1843XMLAttributes_
1844 : XMLAttributes_ XMLAttribute
1845 |
1846 ;
1847
1848XMLAttributes
1849 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1850 | XMLAttributes_ XMLWhitespaceOpt
1851 ;
1852
1853XMLAttributeValue_
1854 : XMLExpression
1855 | XMLAttributeValue
1856 ;
1857
1858XMLAttribute
1859 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1860 ;
1861
1862XMLElementContent
1863 : XMLExpression XMLElementContentOpt
1864 | XMLMarkup XMLElementContentOpt
1865 | XMLText XMLElementContentOpt
1866 | XMLElement XMLElementContentOpt
1867 ;
1868
1869XMLElementContentOpt
1870 : XMLElementContent
1871 |
1872 ;
1873/* }}} */
1874/* 11.1.5 XMLList Initialiser {{{ */
1875XMLListInitialiser
1876 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1877 ;
1878/* }}} */
1879
1880/* 11.2 Left-Hand-Side Expressions {{{ */
1881PropertyIdentifier_
1882 : Identifier { $$ = $1; }
1883 | PropertyIdentifier { $$ = $1; }
1884 ;
1885
1886MemberAccess
1887 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1888 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1889 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1890 ;
1891/* }}} */
1892/* 12.1 The default xml namespace Statement {{{ */
1893/* XXX: DefaultXMLNamespaceStatement
1894 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1895 ;
1896
1897Statement__
1898 : DefaultXMLNamespaceStatement { $$ = $1; }
1899 ; */
1900/* }}} */
1901@end
1902
1903/* JavaScript 1.7: Array Comprehensions {{{ */
1904Comprehension
1905 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
1906 ;
1907
1908ComprehensionFor
1909 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1910 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1911 ;
1912/* }}} */
1913/* JavaScript 1.7: for each {{{ */
1914IterationStatement
1915 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1916 ;
1917/* }}} */
1918/* JavaScript 1.7: let Statements {{{ */
1919LetStatement
1920 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1921 ;
1922
1923Statement__
1924 : LetStatement
1925 ;
1926/* }}} */
1927
1928/* JavaScript FTW: Ruby Blocks {{{ */
1929RubyProcParameterList_
1930 : "," RubyProcParameterList { $$ = $2; }
1931 | { $$ = NULL; }
1932 ;
1933
1934RubyProcParameterList
1935 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1936 | { $$ = NULL; }
1937 ;
1938
1939RubyProcParameters
1940 : "|" RubyProcParameterList "|" { $$ = $2; }
1941 | "||" { $$ = NULL; }
1942 ;
1943
1944RubyProcParametersOpt
1945 : RubyProcParameters
1946 | { $$ = NULL; }
1947 ;
1948
1949RubyProcExpression
1950 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1951 ;
1952
1953PrimaryExpression
1954 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1955 ;
1956
1957CallExpression
1958 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }
1959 ;
1960/* }}} */
1961
1962%%