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