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