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