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