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