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