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