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