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