]> git.saurik.com Git - cycript.git/blob - Cycript.yy.in
3ad89f82c74c37c9c50e97318083d10039ad94ba
[cycript.git] / Cycript.yy.in
1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2014 Jay Freeman (saurik)
3 */
4
5 /* GNU Affero General Public License, Version 3 {{{ */
6 /*
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. 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
114 @if Bison24 %code provides {
115 int cylex(YYSTYPE *, cy::location *, void *);
116 @if Bison24 }
117
118 @if Bison23 %}
119 @if Bison23 %union {
120 @if Bison23 }
121 @if Bison23 %{
122
123 @if Bison24 }
124 @if Bison23 %}
125
126 %name-prefix="cy"
127
128 @if Bison23 %skeleton "lalr1.cc"
129 @if Bison24 %language "C++"
130
131 %initial-action {
132 @$.begin.filename = @$.end.filename = &driver.filename_;
133 };
134
135 %locations
136 %defines
137
138 //%glr-parser
139 //%expect 1
140
141 %error-verbose
142
143 %parse-param { CYDriver &driver }
144 %lex-param { void *cyscanner }
145
146 /* Token Declarations {{{ */
147 @begin E4X
148 %token XMLCDATA
149 %token XMLComment
150 %token XMLPI
151
152 %token XMLAttributeValue
153 %token XMLName
154 %token XMLTagCharacters
155 %token XMLText
156 %token XMLWhitespace
157 @end
158
159 @begin E4X
160 %token LeftRight "<>"
161 %token LeftSlashRight "</>"
162
163 %token SlashRight "/>"
164 %token LeftSlash "</"
165
166 %token ColonColon "::"
167 %token PeriodPeriod ".."
168 @end
169
170 @begin E4X ObjectiveC
171 %token At "@"
172 %token Pound "#"
173 @end
174
175 %token Ampersand "&"
176 %token AmpersandAmpersand "&&"
177 %token AmpersandEqual "&="
178 %token Carrot "^"
179 %token CarrotEqual "^="
180 %token Equal "="
181 %token EqualEqual "=="
182 %token EqualEqualEqual "==="
183 %token EqualRight "=>"
184 %token Exclamation "!"
185 %token ExclamationEqual "!="
186 %token ExclamationEqualEqual "!=="
187 %token Hyphen "-"
188 %token HyphenEqual "-="
189 %token HyphenHyphen "--"
190 %token HyphenHyphen_ "\n--"
191 %token HyphenRight "->"
192 %token Left "<"
193 %token LeftEqual "<="
194 %token LeftLeft "<<"
195 %token LeftLeftEqual "<<="
196 %token Percent "%"
197 %token PercentEqual "%="
198 %token Period "."
199 %token PeriodPeriodPeriod "..."
200 %token Pipe "|"
201 %token PipeEqual "|="
202 %token PipePipe "||"
203 %token Plus "+"
204 %token PlusEqual "+="
205 %token PlusPlus "++"
206 %token PlusPlus_ "\n++"
207 %token Right ">"
208 %token RightEqual ">="
209 %token RightRight ">>"
210 %token RightRightEqual ">>="
211 %token RightRightRight ">>>"
212 %token RightRightRightEqual ">>>="
213 %token Slash "/"
214 %token SlashEqual "/="
215 %token Star "*"
216 %token StarEqual "*="
217 %token Tilde "~"
218
219 %token Colon ":"
220 %token Comma ","
221 %token Question "?"
222 %token SemiColon ";"
223 %token NewLine "\n"
224
225 %token <comment_> Comment
226
227 %token OpenParen "("
228 %token CloseParen ")"
229
230 %token OpenBrace "{"
231 %token OpenBrace_ "\n{"
232 %token OpenBrace__ ";{"
233 %token CloseBrace "}"
234
235 %token OpenBracket "["
236 %token CloseBracket "]"
237
238 %token AtError "@error"
239
240 @begin Java
241 %token AtClass "@class"
242 @end
243
244 @begin C
245 %token <identifier_> Typedef "typedef"
246 %token <identifier_> Unsigned "unsigned"
247 %token <identifier_> Signed "signed"
248 @end
249
250 @begin C
251 %token AtEncode "@encode"
252 @end
253
254 @begin ObjectiveC
255 %token AtImplementation "@implementation"
256 %token AtImplementation_ ";@implementation"
257 %token AtImport "@import"
258 %token AtEnd "@end"
259 %token AtSelector "@selector"
260 %token <identifier_> Yes "YES"
261 %token <identifier_> No "NO"
262 @end
263
264 %token <false_> False "false"
265 %token <null_> Null "null"
266 %token <true_> True "true"
267
268 // ES3/ES5/WIE/JSC Reserved
269 %token <word_> Auto "auto"
270 %token <word_> Break "break"
271 %token <word_> Case "case"
272 %token <word_> Catch "catch"
273 %token <word_> Continue "continue"
274 %token <word_> Default "default"
275 %token <word_> Delete "delete"
276 %token <word_> Do "do"
277 %token <word_> Else "else"
278 %token <word_> Finally "finally"
279 %token <word_> For "for"
280 %token <word_> Function "function"
281 %token <word_> Function_ ";function"
282 %token <word_> If "if"
283 %token <word_> In "in"
284 %token <word_> In_ "!in"
285 %token <word_> InstanceOf "instanceof"
286 %token <word_> New "new"
287 %token <word_> Return "return"
288 %token <word_> Switch "switch"
289 %token <this_> This "this"
290 %token <word_> Throw "throw"
291 %token <word_> Try "try"
292 %token <word_> TypeOf "typeof"
293 %token <word_> Var "var"
294 %token <word_> Void "void"
295 %token <word_> While "while"
296 %token <word_> With "with"
297
298 // ES3/IE6 Future, ES5/JSC Reserved
299 %token <word_> Debugger "debugger"
300
301 // ES3/ES5/IE6 Future, JSC Reserved
302 %token <word_> Const "const"
303
304 // ES3/ES5/IE6/JSC Future
305 %token <word_> Class "class"
306 %token <word_> Enum "enum"
307 %token <word_> Export "export"
308 %token <word_> Extends "extends"
309 %token <word_> Import "import"
310 %token <word_> Super "super"
311
312 // ES3 Future, ES5 Strict Future
313 %token <identifier_> Implements "implements"
314 %token <identifier_> Interface "interface"
315 %token <identifier_> Package "package"
316 %token <identifier_> Private "private"
317 %token <identifier_> Protected "protected"
318 %token <identifier_> Public "public"
319 %token <identifier_> Static "static"
320
321 // ES3 Future
322 %token <identifier_> Abstract "abstract"
323 %token <identifier_> Boolean "boolean"
324 %token <identifier_> Byte "byte"
325 %token <identifier_> Char "char"
326 %token <identifier_> Double "double"
327 %token <identifier_> Final "final"
328 %token <identifier_> Float "float"
329 %token <identifier_> Goto "goto"
330 %token <identifier_> Int "int"
331 %token <identifier_> Long "long"
332 %token <identifier_> Native "native"
333 %token <identifier_> Short "short"
334 %token <identifier_> Synchronized "synchronized"
335 %token <identifier_> Throws "throws"
336 %token <identifier_> Transient "transient"
337 %token <identifier_> Volatile "volatile"
338
339 // ES5 Strict
340 %token <identifier_> Let "let"
341 %token <identifier_> Yield "yield"
342
343 // Woah?!
344 %token <identifier_> Each "each"
345 %token <identifier_> Of "of"
346
347 @begin E4X
348 // E4X Conditional
349 %token <identifier_> Namespace "namespace"
350 %token <identifier_> XML "xml"
351 @end
352
353 %token AutoComplete
354
355 %token <identifier_> Identifier_
356 %token <number_> NumericLiteral
357 %token <string_> StringLiteral
358 %token <literal_> RegularExpressionLiteral
359
360 %type <expression_> AdditiveExpression
361 %type <argument_> ArgumentList_
362 %type <argument_> ArgumentList
363 %type <argument_> ArgumentListOpt
364 %type <argument_> Arguments
365 %type <expression_> ArrayComprehension
366 %type <expression_> ArrayInitialiser
367 %type <literal_> ArrayLiteral
368 %type <expression_> ArrowFunction
369 %type <functionParameter_> ArrowParameters
370 %type <expression_> AssignmentExpression
371 %type <identifier_> Binding
372 %type <identifier_> BindingIdentifier
373 %type <expression_> BitwiseANDExpression
374 %type <statement_> Block_
375 %type <statement_> Block
376 %type <boolean_> BooleanLiteral
377 %type <declaration_> BindingElement
378 %type <expression_> BitwiseORExpression
379 %type <expression_> BitwiseXORExpression
380 %type <statement_> BreakStatement
381 %type <statement_> BreakableStatement
382 %type <expression_> CallExpression_
383 %type <expression_> CallExpression
384 %type <clause_> CaseBlock
385 %type <clause_> CaseClause
386 %type <clause_> CaseClausesOpt
387 %type <catch_> CatchOpt
388 %type <expression_> Comprehension
389 %type <comprehension_> ComprehensionFor
390 %type <comprehension_> ComprehensionIf
391 %type <comprehension_> ComprehensionTail
392 %type <expression_> ConditionalExpression
393 %type <statement_> ContinueStatement
394 %type <statement_> ConciseBody
395 %type <statement_> DebuggerStatement
396 %type <statement_> Declaration__
397 %type <statement_> Declaration_
398 %type <statement_> Declaration
399 %type <clause_> DefaultClause
400 %type <expression_> Element
401 %type <expression_> ElementOpt
402 %type <element_> ElementList
403 %type <element_> ElementListOpt
404 %type <statement_> ElseStatementOpt
405 %type <statement_> EmptyStatement
406 %type <expression_> EqualityExpression
407 %type <compound_> Expression_
408 %type <compound_> Expression
409 %type <expression_> ExpressionOpt
410 %type <statement_> ExpressionStatement
411 %type <finally_> FinallyOpt
412 %type <for_> ForStatementInitialiser
413 %type <forin_> ForInStatementInitialiser
414 %type <declaration_> FormalParameter
415 %type <functionParameter_> FormalParameterList_
416 %type <functionParameter_> FormalParameterList
417 %type <functionParameter_> FormalParameterListOpt
418 %type <statement_> FunctionBody
419 %type <statement_> FunctionDeclaration
420 %type <expression_> FunctionExpression
421 %type <identifier_> Identifier
422 %type <identifier_> IdentifierOpt
423 %type <identifier_> IdentifierType
424 %type <word_> IdentifierName
425 %type <statement_> IfStatement
426 %type <expression_> Initialiser
427 %type <expression_> InitialiserOpt
428 %type <statement_> IterationStatement
429 %type <statement_> LabelledStatement
430 %type <expression_> LeftHandSideExpression
431 %type <statement_> LetStatement
432 %type <statement_> LexicalDeclaration
433 %type <literal_> Literal
434 %type <literal_> ValueLiteral
435 %type <expression_> LogicalANDExpression
436 %type <expression_> LogicalORExpression
437 %type <member_> MemberAccess
438 %type <expression_> MemberExpression_
439 %type <expression_> MemberExpression
440 %type <module_> Module
441 %type <expression_> MultiplicativeExpression
442 %type <expression_> NewExpression
443 %type <null_> NullLiteral
444 %type <literal_> ObjectLiteral
445 %type <compound_> Parenthetical
446 %type <compound_> ParentheticalOpt
447 %type <expression_> PostfixExpression
448 %type <expression_> PrimaryExpression
449 %type <statement_> Program
450 %type <statement_> ProgramBody
451 %type <statement_> ProgramBodyOpt
452 %type <propertyName_> PropertyName_
453 %type <propertyName_> PropertyName
454 %type <property_> PropertyDefinition
455 %type <property_> PropertyDefinitionList_
456 %type <property_> PropertyDefinitionList
457 %type <property_> PropertyDefinitionListOpt
458 %type <expression_> RelationalExpression
459 %type <statement_> ReturnStatement
460 %type <rubyProc_> RubyProcExpression
461 %type <functionParameter_> RubyProcParameterList_
462 %type <functionParameter_> RubyProcParameterList
463 %type <functionParameter_> RubyProcParameters
464 %type <functionParameter_> RubyProcParametersOpt
465 %type <expression_> ShiftExpression
466 %type <declaration_> SingleNameBinding
467 %type <statement_> Statement__
468 %type <statement_> Statement_
469 %type <statement_> Statement
470 %type <statement_> StatementList
471 %type <statement_> StatementListOpt
472 %type <statement_> StatementListItem
473 %type <statement_> SwitchStatement
474 %type <statement_> ThrowStatement
475 %type <statement_> TryStatement
476 %type <expression_> UnaryExpression_
477 %type <expression_> UnaryExpression
478 %type <declaration_> VariableDeclaration
479 %type <declarations_> VariableDeclarationList_
480 %type <declarations_> VariableDeclarationList
481 %type <statement_> VariableStatement
482 %type <statement_> WithStatement
483 %type <word_> Word
484 %type <word_> WordOpt
485 %type <expression_> Variable
486
487 @begin C
488 %type <typedIdentifier_> ArrayedType
489 %type <modifier_> FunctionedType
490 %type <specifier_> IntegerType
491 %type <specifier_> IntegerTypeOpt
492 %type <typedIdentifier_> PrefixedType
493 %type <specifier_> PrimitiveType
494 %type <typedIdentifier_> TypeParenthetical
495 %type <typedIdentifier_> TypeSignifier
496 %type <typedIdentifier_> SuffixedType
497 %type <modifier_> TypeQualifierLeft
498 %type <typedIdentifier_> TypeQualifierRight
499 %type <typedIdentifier_> TypedIdentifier
500 %type <typedParameter_> TypedParameterList_
501 %type <typedParameter_> TypedParameterList
502 %type <typedParameter_> TypedParameterListOpt
503 @end
504
505 @begin ObjectiveC
506 %type <expression_> BoxableExpression
507 %type <statement_> CategoryStatement
508 %type <expression_> ClassExpression
509 %type <field_> ClassFieldListOpt
510 %type <field_> ClassFields
511 %type <statement_> ClassStatement
512 %type <expression_> ClassSuperOpt
513 %type <message_> ClassMessageDeclaration
514 %type <message_> ClassMessageDeclarationListOpt
515 %type <className_> ClassName
516 %type <className_> ClassNameOpt
517 %type <protocol_> ClassProtocolListOpt
518 %type <protocol_> ClassProtocols
519 %type <protocol_> ClassProtocolsOpt
520 %type <expression_> MessageExpression
521 %type <messageParameter_> MessageParameter
522 %type <messageParameter_> MessageParameters
523 %type <messageParameter_> MessageParameterList
524 %type <messageParameter_> MessageParameterListOpt
525 %type <bool_> MessageScope
526 %type <typedIdentifier_> ModifiedType
527 %type <argument_> SelectorCall_
528 %type <argument_> SelectorCall
529 %type <selector_> SelectorExpression_
530 %type <selector_> SelectorExpression
531 %type <selector_> SelectorExpressionOpt
532 %type <argument_> SelectorList
533 %type <word_> SelectorWordOpt
534 %type <typedIdentifier_> TypeOpt
535 %type <argument_> VariadicCall
536 @end
537
538 @begin E4X
539 %type <propertyIdentifier_> PropertyIdentifier_
540 %type <selector_> PropertySelector_
541 %type <selector_> PropertySelector
542 %type <identifier_> QualifiedIdentifier_
543 %type <identifier_> QualifiedIdentifier
544 %type <identifier_> WildcardIdentifier
545 %type <identifier_> XMLComment
546 %type <identifier_> XMLCDATA
547 %type <identifier_> XMLElement
548 %type <identifier_> XMLElementContent
549 %type <identifier_> XMLMarkup
550 %type <identifier_> XMLPI
551
552 %type <attribute_> AttributeIdentifier
553 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
554 %type <expression_> PropertyIdentifier
555 %type <expression_> XMLListInitialiser
556 %type <expression_> XMLInitialiser
557 @end
558 /* }}} */
559 /* Token Priorities {{{ */
560 %nonassoc ""
561 %left "++" "--"
562
563 %nonassoc "if"
564 %nonassoc "else"
565 /* }}} */
566
567 %start Program
568
569 %%
570
571 /* Lexer State {{{ */
572 LexPushInOn
573 : { driver.in_.push(true); }
574 ;
575
576 LexPushInOff
577 : { driver.in_.push(false); }
578 ;
579
580 LexPopIn
581 : { driver.in_.pop(); }
582 ;
583
584 LexSetRegExp
585 : { driver.SetCondition(CYDriver::RegExpCondition); }
586 ;
587
588 LexNoBrace
589 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
590 ;
591
592 LexNoFunction
593 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
594 ;
595
596 LexNoAtImplementation :
597 @begin ObjectiveC
598 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
599 @end
600 ;
601
602 LexSetStatement
603 : LexNoBrace LexNoFunction LexNoAtImplementation
604 ;
605 /* }}} */
606 /* Virtual Tokens {{{ */
607 BRACE
608 : "{"
609 | "\n{"
610 ;
611
612 Var_
613 : "var"
614 ;
615 /* }}} */
616
617 /* 7.6 Identifier Names and Identifiers {{{ */
618 IdentifierName
619 : Word { $$ = $1; }
620 ;
621
622 NewLineOpt
623 : "\n"
624 |
625 ;
626
627 Word
628 : Identifier { $$ = $1; }
629 | "auto" { $$ = $1; }
630 | "break" NewLineOpt { $$ = $1; }
631 | "case" { $$ = $1; }
632 | "catch" { $$ = $1; }
633 | "class" { $$ = $1; }
634 | "const" { $$ = $1; }
635 | "continue" NewLineOpt { $$ = $1; }
636 | "debugger" { $$ = $1; }
637 | "default" { $$ = $1; }
638 | "delete" { $$ = $1; }
639 | "do" { $$ = $1; }
640 | "else" { $$ = $1; }
641 | "enum" { $$ = $1; }
642 | "export" { $$ = $1; }
643 | "extends" { $$ = $1; }
644 | "false" { $$ = $1; }
645 | "finally" { $$ = $1; }
646 /* XXX: | "for" { $$ = $1; } */
647 | "function" { $$ = $1; }
648 | "if" { $$ = $1; }
649 | "import" { $$ = $1; }
650 /* XXX: | "in" { $$ = $1; } */
651 | "!in" { $$ = $1; }
652 /* XXX: | "instanceof" { $$ = $1; } */
653
654 // XXX: as it currently is not an Identifier
655 | "let" { $$ = $1; }
656
657 | "new" { $$ = $1; }
658 | "null" { $$ = $1; }
659 | "return" NewLineOpt { $$ = $1; }
660 | "super" { $$ = $1; }
661 | "switch" { $$ = $1; }
662 | "this" { $$ = $1; }
663 | "throw" NewLineOpt { $$ = $1; }
664 | "true" { $$ = $1; }
665 | "try" { $$ = $1; }
666 | "typeof" { $$ = $1; }
667 | "var" { $$ = $1; }
668 | "void" { $$ = $1; }
669 | "while" { $$ = $1; }
670 | "with" { $$ = $1; }
671 ;
672
673 WordOpt
674 : Word { $$ = $1; }
675 | { $$ = NULL; }
676 ;
677
678 IdentifierType
679 : Identifier_ { $$ = $1; }
680
681 | "implements" { $$ = $1; }
682 | "interface" { $$ = $1; }
683 | "package" { $$ = $1; }
684 | "private" { $$ = $1; }
685 | "protected" { $$ = $1; }
686 | "public" { $$ = $1; }
687 | "static" { $$ = $1; }
688
689 | "abstract" { $$ = $1; }
690 | "boolean" { $$ = $1; }
691 | "byte" { $$ = $1; }
692 | "double" { $$ = $1; }
693 | "final" { $$ = $1; }
694 | "float" { $$ = $1; }
695 | "goto" { $$ = $1; }
696 | "native" { $$ = $1; }
697 | "synchronized" { $$ = $1; }
698 | "throws" { $$ = $1; }
699 | "transient" { $$ = $1; }
700
701 // XXX: currently I only have this as Word
702 // | "let" { $$ = $1; }
703
704 | "yield" { $$ = $1; }
705
706 | "each" { $$ = $1; }
707 | "of" { $$ = $1; }
708 ;
709
710 Identifier
711 : IdentifierType
712 | "char" { $$ = $1; }
713 | "int" { $$ = $1; }
714 | "long" { $$ = $1; }
715 | "short" { $$ = $1; }
716 | "volatile" { $$ = $1; }
717 @begin C
718 | "typedef" { $$ = $1; }
719 | "unsigned" { $$ = $1; }
720 | "signed" { $$ = $1; }
721 @end
722 @begin ObjectiveC
723 | "YES" { $$ = $1; }
724 | "NO" { $$ = $1; }
725 @end
726 ;
727
728 IdentifierOpt
729 : Identifier { $$ = $1; }
730 | { $$ = NULL; }
731 ;
732 /* }}} */
733
734 /* 7.8 Literals {{{ */
735 Literal
736 : NullLiteral { $$ = $1; }
737 | ValueLiteral { $$ = $1; }
738 ;
739
740 ValueLiteral
741 : BooleanLiteral { $$ = $1; }
742 | NumericLiteral { $$ = $1; }
743 | StringLiteral { $$ = $1; }
744 | RegularExpressionLiteral { $$ = $1; }
745 ;
746 /* }}} */
747 /* 7.8.1 Null Literals {{{ */
748 NullLiteral
749 : "null" { $$ = $1; }
750 ;
751 /* }}} */
752 /* 7.8.2 Boolean Literals {{{ */
753 BooleanLiteral
754 : "true" { $$ = $1; }
755 | "false" { $$ = $1; }
756 ;
757 /* }}} */
758
759 /* 7.9 Automatic Semicolon Insertion {{{ */
760 StrictSemi
761 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
762 ;
763
764 Terminator
765 : ";"
766 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
767 ;
768
769 TerminatorOpt
770 : ";"
771 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
772 ;
773 /* }}} */
774
775 /* 11.1 Primary Expressions {{{ */
776 Parenthetical
777 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
778 ;
779
780 ParentheticalOpt
781 : Parenthetical { $$ = $1; }
782 | { $$ = NULL; }
783 ;
784
785 Variable
786 : Identifier { $$ = CYNew CYVariable($1); }
787 ;
788
789 PrimaryExpression
790 : "this" { $$ = $1; }
791 | Variable { $$ = $1; }
792 | Literal { $$ = $1; }
793 | ArrayInitialiser { $$ = $1; }
794 | ObjectLiteral { $$ = $1; }
795 | Parenthetical { $$ = $1; }
796 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
797 ;
798 /* }}} */
799 /* 11.1.4 Array Initializer {{{ */
800 ArrayInitialiser
801 : ArrayLiteral { $$ = $1; }
802 | ArrayComprehension { $$ = $1; }
803 ;
804 /* }}} */
805 /* 11.1.4.1 Array Literal {{{ */
806 ArrayLiteral
807 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
808 ;
809
810 Element
811 : AssignmentExpression { $$ = $1; }
812 ;
813
814 ElementOpt
815 : Element { $$ = $1; }
816 | LexSetRegExp { $$ = NULL; }
817 ;
818
819 ElementList
820 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
821 | Element { $$ = CYNew CYElement($1, NULL); }
822 ;
823
824 ElementListOpt
825 : ElementList { $$ = $1; }
826 | LexSetRegExp { $$ = NULL; }
827 ;
828 /* }}} */
829 /* 11.1.4.2 Array Comprehension {{{ */
830 ArrayComprehension
831 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
832 ;
833
834 Comprehension
835 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
836 ;
837
838 ComprehensionTail
839 : { $$ = NULL; }
840 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
841 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
842 ;
843
844 ComprehensionFor
845 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
846 ;
847
848 ComprehensionIf
849 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
850 ;
851 /* }}} */
852 /* 11.1.5 Object Initialiser {{{ */
853 ObjectLiteral
854 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
855 ;
856
857 PropertyDefinitionList_
858 : "," PropertyDefinitionList { $$ = $2; }
859 | "," LexSetRegExp { $$ = NULL; }
860 | { $$ = NULL; }
861 ;
862
863 PropertyDefinitionList
864 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
865 ;
866
867 PropertyDefinitionListOpt
868 : PropertyDefinitionList { $$ = $1; }
869 | LexSetRegExp { $$ = NULL; }
870 ;
871
872 PropertyDefinition
873 // XXX: this should be IdentifierName
874 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
875 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
876 //| MethodDefinition
877 ;
878
879 PropertyName_
880 : IdentifierName { $$ = $1; }
881 | StringLiteral { $$ = $1; }
882 | NumericLiteral { $$ = $1; }
883 ;
884
885 PropertyName
886 : LexSetRegExp PropertyName_ { $$ = $2; }
887 ;
888 /* }}} */
889
890 /* 11.2 Left-Hand-Side Expressions {{{ */
891 MemberAccess
892 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
893 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
894 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
895 ;
896
897 MemberExpression_
898 : MemberExpression { $$ = $1; }
899 //| "super" { $$ = $1; }
900 ;
901
902 MemberExpression
903 : LexSetRegExp PrimaryExpression { $$ = $2; }
904 | LexSetRegExp FunctionExpression { $$ = $2; }
905 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
906 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
907 ;
908
909 NewExpression
910 : MemberExpression { $$ = $1; }
911 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
912 ;
913
914 CallExpression_
915 : MemberExpression_
916 | CallExpression
917 ;
918
919 CallExpression
920 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
921 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
922 ;
923
924 Arguments
925 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
926 ;
927
928 ArgumentList_
929 : "," ArgumentList { $$ = $2; }
930 | { $$ = NULL; }
931 ;
932
933 ArgumentList
934 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
935 ;
936
937 ArgumentListOpt
938 : ArgumentList { $$ = $1; }
939 | LexSetRegExp { $$ = NULL; }
940 ;
941
942 LeftHandSideExpression
943 : NewExpression { $$ = $1; }
944 | CallExpression { $$ = $1; }
945 ;
946 /* }}} */
947 /* 11.3 Postfix Expressions {{{ */
948 PostfixExpression
949 : %prec "" LeftHandSideExpression { $$ = $1; }
950 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
951 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
952 ;
953 /* }}} */
954 /* 11.4 Unary Operators {{{ */
955 UnaryExpression_
956 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
957 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
958 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
959 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
960 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
961 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
962 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
963 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
964 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
965 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
966 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
967 ;
968
969 UnaryExpression
970 : PostfixExpression { $$ = $1; }
971 | LexSetRegExp UnaryExpression_ { $$ = $2; }
972 ;
973 /* }}} */
974 /* 11.5 Multiplicative Operators {{{ */
975 MultiplicativeExpression
976 : UnaryExpression { $$ = $1; }
977 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
978 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
979 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
980 ;
981 /* }}} */
982 /* 11.6 Additive Operators {{{ */
983 AdditiveExpression
984 : MultiplicativeExpression { $$ = $1; }
985 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
986 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
987 ;
988 /* }}} */
989 /* 11.7 Bitwise Shift Operators {{{ */
990 ShiftExpression
991 : AdditiveExpression { $$ = $1; }
992 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
993 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
994 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
995 ;
996 /* }}} */
997 /* 11.8 Relational Operators {{{ */
998 RelationalExpression
999 : ShiftExpression { $$ = $1; }
1000 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1001 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1002 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1003 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1004 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1005 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1006 ;
1007 /* }}} */
1008 /* 11.9 Equality Operators {{{ */
1009 EqualityExpression
1010 : RelationalExpression { $$ = $1; }
1011 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1012 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1013 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1014 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1015 ;
1016 /* }}} */
1017 /* 11.10 Binary Bitwise Operators {{{ */
1018 BitwiseANDExpression
1019 : EqualityExpression { $$ = $1; }
1020 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1021 ;
1022
1023 BitwiseXORExpression
1024 : BitwiseANDExpression { $$ = $1; }
1025 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1026 ;
1027
1028 BitwiseORExpression
1029 : BitwiseXORExpression { $$ = $1; }
1030 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1031 ;
1032 /* }}} */
1033 /* 11.11 Binary Logical Operators {{{ */
1034 LogicalANDExpression
1035 : BitwiseORExpression { $$ = $1; }
1036 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1037 ;
1038
1039 LogicalORExpression
1040 : LogicalANDExpression { $$ = $1; }
1041 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1042 ;
1043 /* }}} */
1044 /* 11.12 Conditional Operator ( ? : ) {{{ */
1045 ConditionalExpression
1046 : LogicalORExpression { $$ = $1; }
1047 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1048 | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1049 ;
1050 /* }}} */
1051 /* 11.13 Assignment Operators {{{ */
1052 AssignmentExpression
1053 : ConditionalExpression { $$ = $1; }
1054 | ArrowFunction { $$ = $1; }
1055 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1056 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1057 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1058 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1059 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1060 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1061 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1062 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1063 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1064 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1065 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1066 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1067 ;
1068 /* }}} */
1069 /* 11.14 Comma Operator {{{ */
1070 Expression_
1071 : "," Expression { $$ = $2; }
1072 | { $$ = NULL; }
1073 ;
1074
1075 Expression
1076 : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); }
1077 ;
1078
1079 ExpressionOpt
1080 : Expression { $$ = $1; }
1081 | LexSetRegExp { $$ = NULL; }
1082 ;
1083 /* }}} */
1084
1085 /* 12 Statements {{{ */
1086 Statement__
1087 : Block { $$ = $1; }
1088 | VariableStatement { $$ = $1; }
1089 | EmptyStatement { $$ = $1; }
1090 | IfStatement { $$ = $1; }
1091 | BreakableStatement { $$ = $1; }
1092 | ContinueStatement { $$ = $1; }
1093 | BreakStatement { $$ = $1; }
1094 | ReturnStatement { $$ = $1; }
1095 | WithStatement { $$ = $1; }
1096 | LabelledStatement { $$ = $1; }
1097 | ThrowStatement { $$ = $1; }
1098 | TryStatement { $$ = $1; }
1099 | DebuggerStatement { $$ = $1; }
1100 ;
1101
1102 Statement_
1103 : LexSetRegExp Statement__ { $$ = $2; }
1104 | ExpressionStatement { $$ = $1; }
1105 ;
1106
1107 Statement
1108 : LexSetStatement Statement_ { $$ = $2; }
1109 ;
1110
1111 Declaration__
1112 : FunctionDeclaration { $$ = $1; }
1113 | LexicalDeclaration { $$ = $1; }
1114 ;
1115
1116 Declaration_
1117 : LexSetRegExp Declaration__ { $$ = $2; }
1118 ;
1119
1120 Declaration
1121 : LexSetStatement Declaration_ { $$ = $2; }
1122 ;
1123
1124 BreakableStatement
1125 : IterationStatement { $$ = $1; }
1126 | SwitchStatement { $$ = $1; }
1127 ;
1128 /* }}} */
1129 /* 12.1 Block {{{ */
1130 Block_
1131 : BRACE StatementListOpt "}" { $$ = $2; }
1132 ;
1133
1134 Block
1135 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1136 ;
1137
1138 StatementList
1139 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1140 ;
1141
1142 StatementListOpt
1143 : StatementList { $$ = $1; }
1144 | LexSetStatement LexSetRegExp { $$ = NULL; }
1145 ;
1146
1147 StatementListItem
1148 : Statement { $$ = $1; }
1149 | Declaration { $$ = $1; }
1150 ;
1151 /* }}} */
1152
1153 /* 12.2 Declarations {{{ */
1154 BindingIdentifier
1155 : Identifier { $$ = $1; }
1156 ;
1157
1158 Binding
1159 : BindingIdentifier
1160 ;
1161
1162 // XXX: BindingPattern
1163 /* }}} */
1164 /* 12.2.1 Let and Const Declarations {{{ */
1165 LexicalDeclaration
1166 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1167 ;
1168
1169 LetOrConst
1170 : "let"
1171 | "const"
1172 ;
1173 /* }}} */
1174 /* 12.2.2 Variable Statement {{{ */
1175 VariableStatement
1176 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1177 ;
1178
1179 VariableDeclarationList_
1180 : "," VariableDeclarationList { $$ = $2; }
1181 | { $$ = NULL; }
1182 ;
1183
1184 VariableDeclarationList
1185 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1186 ;
1187
1188 VariableDeclaration
1189 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1190 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1191 ;
1192
1193 Initialiser
1194 : "=" AssignmentExpression { $$ = $2; }
1195 ;
1196
1197 InitialiserOpt
1198 : Initialiser { $$ = $1; }
1199 | { $$ = NULL; }
1200 ;
1201 /* }}} */
1202 /* 12.2.4 Destructuring Binding Patterns {{{ */
1203 // XXX: *
1204
1205 BindingElement
1206 : SingleNameBinding { $$ = $1; }
1207 ;
1208
1209 SingleNameBinding
1210 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1211 ;
1212 /* }}} */
1213
1214 /* 12.3 Empty Statement {{{ */
1215 EmptyStatement
1216 : ";" { $$ = CYNew CYEmpty(); }
1217 ;
1218 /* }}} */
1219 /* 12.4 Expression Statement {{{ */
1220 ExpressionStatement
1221 : Expression Terminator { $$ = CYNew CYExpress($1); }
1222 ;
1223 /* }}} */
1224 /* 12.5 The if Statement {{{ */
1225 ElseStatementOpt
1226 : "else" Statement { $$ = $2; }
1227 | %prec "if" { $$ = NULL; }
1228 ;
1229
1230 IfStatement
1231 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1232 ;
1233 /* }}} */
1234
1235 /* 12.6.1 The do-while Statement {{{ */
1236 IterationStatement
1237 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1238 ;
1239 /* }}} */
1240 /* 12.6.2 The while Statement {{{ */
1241 IterationStatement
1242 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1243 ;
1244 /* }}} */
1245 /* 12.6.3 The for Statement {{{ */
1246 IterationStatement
1247 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1248 ;
1249
1250 ForStatementInitialiser
1251 : ExpressionOpt { $$ = $1; }
1252 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1253 ;
1254 /* }}} */
1255 /* 12.6.4 The for-in and for-of Statements {{{ */
1256 IterationStatement
1257 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1258 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1259 ;
1260
1261 ForInStatementInitialiser
1262 : LeftHandSideExpression { $$ = $1; }
1263 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1264 ;
1265 /* }}} */
1266
1267 /* 12.7 The continue Statement {{{ */
1268 ContinueStatement
1269 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1270 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1271 ;
1272 /* }}} */
1273 /* 12.8 The break Statement {{{ */
1274 BreakStatement
1275 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1276 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1277 ;
1278 /* }}} */
1279 /* 12.9 The return Statement {{{ */
1280 ReturnStatement
1281 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1282 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1283 ;
1284 /* }}} */
1285 /* 12.10 The with Statement {{{ */
1286 WithStatement
1287 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1288 ;
1289 /* }}} */
1290
1291 /* 12.11 The switch Statement {{{ */
1292 SwitchStatement
1293 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1294 ;
1295
1296 CaseBlock
1297 : BRACE CaseClausesOpt "}" { $$ = $2; }
1298 ;
1299
1300 CaseClause
1301 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1302 ;
1303
1304 CaseClausesOpt
1305 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1306 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1307 | { $$ = NULL; }
1308 ;
1309
1310 DefaultClause
1311 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1312 ;
1313 /* }}} */
1314 /* 12.12 Labelled Statements {{{ */
1315 LabelledStatement
1316 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1317 ;
1318 /* }}} */
1319 /* 12.13 The throw Statement {{{ */
1320 ThrowStatement
1321 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1322 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1323 ;
1324 /* }}} */
1325 /* 12.14 The try Statement {{{ */
1326 TryStatement
1327 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1328 ;
1329
1330 CatchOpt
1331 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1332 | { $$ = NULL; }
1333 ;
1334
1335 FinallyOpt
1336 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1337 | { $$ = NULL; }
1338 ;
1339 /* }}} */
1340 /* 12.14 The debugger Statement {{{ */
1341 DebuggerStatement
1342 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1343 ;
1344 /* }}} */
1345
1346 /* 13.1 Function Definitions {{{ */
1347 FunctionDeclaration
1348 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1349 ;
1350
1351 FunctionExpression
1352 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1353 ;
1354
1355 FormalParameterList_
1356 : "," FormalParameterList { $$ = $2; }
1357 | { $$ = NULL; }
1358 ;
1359
1360 FormalParameterList
1361 // XXX: : FunctionRestParameter { $$ = $1; }
1362 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1363 ;
1364
1365 FormalParameterListOpt
1366 : FormalParameterList
1367 | { $$ = NULL; }
1368 ;
1369
1370 /* XXX: FunctionRestParameter
1371 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1372 ;*/
1373
1374 FormalParameter
1375 : BindingElement { $$ = $1; }
1376 ;
1377
1378 FunctionBody
1379 : StatementListOpt { $$ = $1; }
1380 ;
1381 /* }}} */
1382 /* 13.2 Arrow Function Definitions {{{ */
1383 ArrowFunction
1384 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1385 ;
1386
1387 ArrowParameters
1388 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1389 //| ParentheticalOpt { $$ = $1; }
1390 ;
1391
1392 ConciseBody
1393 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1394 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1395 ;
1396 /* }}} */
1397 /* 14 Program {{{ */
1398 Program
1399 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1400 ;
1401
1402 ProgramBody
1403 : StatementList { $$ = $1; }
1404 ;
1405
1406 ProgramBodyOpt
1407 : ProgramBody { $$ = $1; }
1408 | LexSetStatement LexSetRegExp { $$ = NULL; }
1409 ;
1410 /* }}} */
1411
1412 @begin C
1413 /* Cycript (C): Type Encoding {{{ */
1414 TypeParenthetical
1415 : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1416 ;
1417
1418 TypeSignifier
1419 : IdentifierType { $$ = CYNew CYTypedIdentifier($1); }
1420 | TypeParenthetical { $$ = $1; }
1421 ;
1422
1423 ArrayedType
1424 : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1425 | TypeSignifier { $$ = $1; }
1426 | { $$ = CYNew CYTypedIdentifier(); }
1427 ;
1428
1429 FunctionedType
1430 : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); }
1431 ;
1432
1433 SuffixedType
1434 : ArrayedType { $$ = $1; }
1435 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1436 | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1437 | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1438 ;
1439
1440 PrefixedType
1441 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1442 ;
1443
1444 TypeQualifierLeft
1445 : { $$ = NULL; }
1446 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1447 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1448 ;
1449
1450 TypeQualifierRight
1451 : PrefixedType { $$ = $1; }
1452 | SuffixedType { $$ = $1; }
1453 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1454 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1455 ;
1456
1457 IntegerType
1458 : "int" { $$ = CYNew CYTypeVariable("int"); }
1459 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1460 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1461 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1462 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1463 ;
1464
1465 IntegerTypeOpt
1466 : IntegerType { $$ = $1; }
1467 | { $$ = CYNew CYTypeVariable("int"); }
1468 ;
1469
1470 PrimitiveType
1471 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1472 | IntegerType { $$ = $1; }
1473 | "void" { $$ = CYNew CYTypeVoid(); }
1474 | "char" { $$ = CYNew CYTypeVariable("char"); }
1475 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1476 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1477 ;
1478
1479 TypedIdentifier
1480 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1481 ;
1482
1483 PrimaryExpression
1484 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($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 TypedIdentifier ")" { $$ = $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 %%