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