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