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