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