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