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