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