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