1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2013 Jay Freeman (saurik)
5 /* GNU General Public License, Version 3 {{{ */
7 * Cycript is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
12 * Cycript is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
24 @if Bison24 %code top {
25 #define cyscanner driver.scanner_
26 #define YYSTACKEXPANDABLE 1
27 @if Bison23 #define yyerrok (yyerrstatus_ = 0)
30 @if Bison24 %code requires {
33 #define CYNew new($pool)
36 #include "ObjectiveC/Syntax.hpp"
40 #include "E4X/Syntax.hpp"
43 #include "Highlight.hpp"
52 CYDriver::Condition condition_;
54 CYArgument *argument_;
55 CYAssignment *assignment_;
58 cy::Syntax::Catch *catch_;
60 CYComprehension *comprehension_;
61 CYCompound *compound_;
62 CYDeclaration *declaration_;
63 CYDeclarations *declarations_;
65 CYExpression *expression_;
68 CYForInitialiser *for_;
69 CYForInInitialiser *forin_;
70 CYFunctionParameter *functionParameter_;
71 CYIdentifier *identifier_;
78 CYProperty *property_;
79 CYPropertyName *propertyName_;
80 CYRubyProc *rubyProc_;
81 CYStatement *statement_;
88 CYClassName *className_;
91 CYMessageParameter *messageParameter_;
92 CYProtocol *protocol_;
93 CYSelectorPart *selector_;
94 CYTypeModifier *type_;
95 CYTypedIdentifier *typedIdentifier_;
96 CYTypedParameter *typedParameter_;
100 CYAttribute *attribute_;
101 CYPropertyIdentifier *propertyIdentifier_;
102 CYSelector *selector_;
107 #define YYSTYPE YYSTYPE
110 @if Bison24 %code provides {
111 int cylex(YYSTYPE *, cy::location *, void *);
118 @if Bison23 %skeleton "lalr1.cc"
119 @if Bison24 %language "C++"
122 @$.begin.filename = @$.end.filename = &driver.filename_;
133 %parse-param { CYDriver &driver }
134 %lex-param { void *cyscanner }
136 /* Token Declarations {{{ */
142 %token XMLAttributeValue
144 %token XMLTagCharacters
150 %token LeftRight "<>"
151 %token LeftSlashRight "</>"
153 %token SlashRight "/>"
154 %token LeftSlash "</"
156 %token ColonColon "::"
157 %token PeriodPeriod ".."
160 @begin E4X ObjectiveC
165 %token AmpersandAmpersand "&&"
166 %token AmpersandEqual "&="
168 %token CarrotEqual "^="
170 %token EqualEqual "=="
171 %token EqualEqualEqual "==="
172 %token EqualRight "=>"
173 %token Exclamation "!"
174 %token ExclamationEqual "!="
175 %token ExclamationEqualEqual "!=="
177 %token HyphenEqual "-="
178 %token HyphenHyphen "--"
179 %token HyphenHyphen_ "\n--"
180 %token HyphenRight "->"
182 %token LeftEqual "<="
184 %token LeftLeftEqual "<<="
186 %token PercentEqual "%="
188 %token PeriodPeriodPeriod "..."
190 %token PipeEqual "|="
193 %token PlusEqual "+="
195 %token PlusPlus_ "\n++"
197 %token RightEqual ">="
198 %token RightRight ">>"
199 %token RightRightEqual ">>="
200 %token RightRightRight ">>>"
201 %token RightRightRightEqual ">>>="
203 %token SlashEqual "/="
205 %token StarEqual "*="
214 %token <comment_> Comment
217 %token CloseParen ")"
220 %token OpenBrace_ "\n{"
221 %token OpenBrace__ ";{"
222 %token CloseBrace "}"
224 %token OpenBracket "["
225 %token CloseBracket "]"
227 %token AtError "@error"
230 %token AtClass "@class"
234 %token <identifier_> Typedef "typedef"
238 %token AtImplementation "@implementation"
239 %token AtImplementation_ ";@implementation"
240 %token AtImport "@import"
241 %token AtEncode "@encode"
243 %token AtSelector "@selector"
246 %token <false_> False "false"
247 %token <null_> Null "null"
248 %token <true_> True "true"
250 // ES3/ES5/WIE/JSC Reserved
251 %token <word_> Auto "auto"
252 %token <word_> Break "break"
253 %token <word_> Case "case"
254 %token <word_> Catch "catch"
255 %token <word_> Continue "continue"
256 %token <word_> Default "default"
257 %token <word_> Delete "delete"
258 %token <word_> Do "do"
259 %token <word_> Else "else"
260 %token <word_> Finally "finally"
261 %token <word_> For "for"
262 %token <word_> Function "function"
263 %token <word_> Function_ ";function"
264 %token <word_> If "if"
265 %token <word_> In "in"
266 %token <word_> In_ "!in"
267 %token <word_> InstanceOf "instanceof"
268 %token <word_> New "new"
269 %token <word_> Return "return"
270 %token <word_> Switch "switch"
271 %token <this_> This "this"
272 %token <word_> Throw "throw"
273 %token <word_> Try "try"
274 %token <word_> TypeOf "typeof"
275 %token <word_> Var "var"
276 %token <word_> Void "void"
277 %token <word_> While "while"
278 %token <word_> With "with"
280 // ES3/IE6 Future, ES5/JSC Reserved
281 %token <word_> Debugger "debugger"
283 // ES3/ES5/IE6 Future, JSC Reserved
284 %token <word_> Const "const"
286 // ES3/ES5/IE6/JSC Future
287 %token <word_> Class "class"
288 %token <word_> Enum "enum"
289 %token <word_> Export "export"
290 %token <word_> Extends "extends"
291 %token <word_> Import "import"
292 %token <word_> Super "super"
294 // ES3 Future, ES5 Strict Future
295 %token <identifier_> Implements "implements"
296 %token <identifier_> Interface "interface"
297 %token <identifier_> Package "package"
298 %token <identifier_> Private "private"
299 %token <identifier_> Protected "protected"
300 %token <identifier_> Public "public"
301 %token <identifier_> Static "static"
304 %token <identifier_> Abstract "abstract"
305 %token <identifier_> Boolean "boolean"
306 %token <identifier_> Byte "byte"
307 %token <identifier_> Char "char"
308 %token <identifier_> Double "double"
309 %token <identifier_> Final "final"
310 %token <identifier_> Float "float"
311 %token <identifier_> Goto "goto"
312 %token <identifier_> Int "int"
313 %token <identifier_> Long "long"
314 %token <identifier_> Native "native"
315 %token <identifier_> Short "short"
316 %token <identifier_> Synchronized "synchronized"
317 %token <identifier_> Throws "throws"
318 %token <identifier_> Transient "transient"
319 %token <identifier_> Volatile "volatile"
322 %token <identifier_> Let "let"
323 %token <identifier_> Yield "yield"
326 %token <identifier_> Each "each"
327 %token <identifier_> Of "of"
331 %token <identifier_> Namespace "namespace"
332 %token <identifier_> XML "xml"
337 %token <identifier_> Identifier_
338 %token <number_> NumericLiteral
339 %token <string_> StringLiteral
340 %token <literal_> RegularExpressionLiteral
342 %type <expression_> AdditiveExpression
343 %type <argument_> ArgumentList_
344 %type <argument_> ArgumentList
345 %type <argument_> ArgumentListOpt
346 %type <argument_> Arguments
347 %type <literal_> ArrayLiteral
348 %type <expression_> ArrowFunction
349 %type <functionParameter_> ArrowParameters
350 %type <expression_> AssignmentExpression
351 %type <identifier_> Binding
352 %type <identifier_> BindingIdentifier
353 %type <expression_> BitwiseANDExpression
354 %type <statement_> Block_
355 %type <statement_> Block
356 %type <boolean_> BooleanLiteral
357 %type <declaration_> BindingElement
358 %type <expression_> BitwiseORExpression
359 %type <expression_> BitwiseXORExpression
360 %type <statement_> BreakStatement
361 %type <statement_> BreakableStatement
362 %type <expression_> CallExpression_
363 %type <expression_> CallExpression
364 %type <clause_> CaseBlock
365 %type <clause_> CaseClause
366 %type <clause_> CaseClausesOpt
367 %type <catch_> CatchOpt
368 %type <comprehension_> ComprehensionForList
369 %type <comprehension_> ComprehensionForListOpt
370 %type <comprehension_> ComprehensionList
371 %type <comprehension_> ComprehensionListOpt
372 %type <expression_> ConditionalExpression
373 %type <statement_> ContinueStatement
374 %type <statement_> ConciseBody
375 %type <statement_> DebuggerStatement
376 %type <statement_> Declaration__
377 %type <statement_> Declaration_
378 %type <statement_> Declaration
379 %type <clause_> DefaultClause
380 %type <expression_> Element
381 %type <expression_> ElementOpt
382 %type <element_> ElementList
383 %type <element_> ElementListOpt
384 %type <statement_> ElseStatementOpt
385 %type <statement_> EmptyStatement
386 %type <expression_> EqualityExpression
387 %type <compound_> Expression_
388 %type <compound_> Expression
389 %type <expression_> ExpressionOpt
390 %type <statement_> ExpressionStatement
391 %type <finally_> FinallyOpt
392 %type <comprehension_> ForComprehension
393 %type <for_> ForStatementInitialiser
394 %type <forin_> ForInStatementInitialiser
395 %type <declaration_> FormalParameter
396 %type <functionParameter_> FormalParameterList_
397 %type <functionParameter_> FormalParameterList
398 %type <functionParameter_> FormalParameterListOpt
399 %type <statement_> FunctionBody
400 %type <statement_> FunctionDeclaration
401 %type <expression_> FunctionExpression
402 %type <identifier_> Identifier
403 %type <identifier_> IdentifierOpt
404 %type <word_> IdentifierName
405 %type <comprehension_> IfComprehension
406 %type <statement_> IfStatement
407 %type <expression_> Initialiser
408 %type <expression_> InitialiserOpt
409 %type <statement_> IterationStatement
410 %type <statement_> LabelledStatement
411 %type <expression_> LeftHandSideExpression
412 %type <statement_> LetStatement
413 %type <statement_> LexicalDeclaration
414 %type <literal_> Literal
415 %type <literal_> ValueLiteral
416 %type <expression_> LogicalANDExpression
417 %type <expression_> LogicalORExpression
418 %type <member_> MemberAccess
419 %type <expression_> MemberExpression_
420 %type <expression_> MemberExpression
421 %type <expression_> MultiplicativeExpression
422 %type <expression_> NewExpression
423 %type <null_> NullLiteral
424 %type <literal_> ObjectLiteral
425 %type <compound_> Parenthetical
426 %type <compound_> ParentheticalOpt
427 %type <expression_> PostfixExpression
428 %type <expression_> PrimaryExpression
429 %type <statement_> Program
430 %type <statement_> ProgramBody
431 %type <statement_> ProgramBodyOpt
432 %type <propertyName_> PropertyName_
433 %type <propertyName_> PropertyName
434 %type <property_> PropertyDefinition
435 %type <property_> PropertyDefinitionList_
436 %type <property_> PropertyDefinitionList
437 %type <property_> PropertyDefinitionListOpt
438 %type <expression_> RelationalExpression
439 %type <statement_> ReturnStatement
440 %type <rubyProc_> RubyProcExpression
441 %type <functionParameter_> RubyProcParameterList_
442 %type <functionParameter_> RubyProcParameterList
443 %type <functionParameter_> RubyProcParameters
444 %type <functionParameter_> RubyProcParametersOpt
445 %type <expression_> ShiftExpression
446 %type <declaration_> SingleNameBinding
447 %type <statement_> Statement__
448 %type <statement_> Statement_
449 %type <statement_> Statement
450 %type <statement_> StatementList
451 %type <statement_> StatementListOpt
452 %type <statement_> StatementListItem
453 %type <statement_> SwitchStatement
454 %type <statement_> ThrowStatement
455 %type <statement_> TryStatement
456 %type <expression_> UnaryExpression_
457 %type <expression_> UnaryExpression
458 %type <declaration_> VariableDeclaration
459 %type <declarations_> VariableDeclarationList_
460 %type <declarations_> VariableDeclarationList
461 %type <statement_> VariableStatement
462 %type <statement_> WithStatement
464 %type <word_> WordOpt
465 %type <expression_> Variable
468 %type <expression_> BoxableExpression
469 %type <statement_> CategoryStatement
470 %type <expression_> ClassExpression
471 %type <field_> ClassFieldListOpt
472 %type <field_> ClassFields
473 %type <statement_> ClassStatement
474 %type <expression_> ClassSuperOpt
475 %type <message_> ClassMessageDeclaration
476 %type <message_> ClassMessageDeclarationListOpt
477 %type <className_> ClassName
478 %type <className_> ClassNameOpt
479 %type <protocol_> ClassProtocolListOpt
480 %type <protocol_> ClassProtocols
481 %type <protocol_> ClassProtocolsOpt
482 %type <expression_> EncodedType
483 %type <expression_> MessageExpression
484 %type <messageParameter_> MessageParameter
485 %type <messageParameter_> MessageParameters
486 %type <messageParameter_> MessageParameterList
487 %type <messageParameter_> MessageParameterListOpt
488 %type <bool_> MessageScope
489 %type <type_> ModifiedType
490 %type <typedIdentifier_> PrefixedType
491 %type <expression_> PrimitiveType
492 %type <type_> QualifiedType
493 %type <argument_> SelectorCall_
494 %type <argument_> SelectorCall
495 %type <selector_> SelectorExpression_
496 %type <selector_> SelectorExpression
497 %type <selector_> SelectorExpressionOpt
498 %type <argument_> SelectorList
499 %type <word_> SelectorWordOpt
500 %type <typedIdentifier_> SuffixedType
501 %type <expression_> TypeOpt
502 %type <typedIdentifier_> TypedIdentifier
503 %type <typedParameter_> TypedParameterList_
504 %type <typedParameter_> TypedParameterList
505 %type <typedParameter_> TypedParameterListOpt
506 %type <argument_> VariadicCall
510 %type <propertyIdentifier_> PropertyIdentifier_
511 %type <selector_> PropertySelector_
512 %type <selector_> PropertySelector
513 %type <identifier_> QualifiedIdentifier_
514 %type <identifier_> QualifiedIdentifier
515 %type <identifier_> WildcardIdentifier
516 %type <identifier_> XMLComment
517 %type <identifier_> XMLCDATA
518 %type <identifier_> XMLElement
519 %type <identifier_> XMLElementContent
520 %type <identifier_> XMLMarkup
521 %type <identifier_> XMLPI
523 %type <attribute_> AttributeIdentifier
524 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
525 %type <expression_> PropertyIdentifier
526 %type <expression_> XMLListInitialiser
527 %type <expression_> XMLInitialiser
530 /* Token Priorities {{{ */
542 /* Lexer State {{{ */
544 : { driver.in_.push(true); }
548 : { driver.in_.push(false); }
552 : { driver.in_.pop(); }
556 : { driver.SetCondition(CYDriver::RegExpCondition); }
560 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
564 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
567 LexNoAtImplementation :
569 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
574 : LexNoBrace LexNoFunction LexNoAtImplementation
577 /* Virtual Tokens {{{ */
588 /* 7.6 Identifier Names and Identifiers {{{ */
599 : Identifier { $$ = $1; }
600 | "auto" { $$ = $1; }
601 | "break" NewLineOpt { $$ = $1; }
602 | "case" { $$ = $1; }
603 | "catch" { $$ = $1; }
604 | "class" { $$ = $1; }
605 | "const" { $$ = $1; }
606 | "continue" NewLineOpt { $$ = $1; }
607 | "debugger" { $$ = $1; }
608 | "default" { $$ = $1; }
609 | "delete" { $$ = $1; }
611 | "else" { $$ = $1; }
612 | "enum" { $$ = $1; }
613 | "export" { $$ = $1; }
614 | "extends" { $$ = $1; }
615 | "false" { $$ = $1; }
616 | "finally" { $$ = $1; }
617 /* XXX: | "for" { $$ = $1; } */
618 | "function" { $$ = $1; }
620 | "import" { $$ = $1; }
621 /* XXX: | "in" { $$ = $1; } */
623 /* XXX: | "instanceof" { $$ = $1; } */
625 // XXX: as it currently is not an Identifier
629 | "null" { $$ = $1; }
630 | "return" NewLineOpt { $$ = $1; }
631 | "super" { $$ = $1; }
632 | "switch" { $$ = $1; }
633 | "this" { $$ = $1; }
634 | "throw" NewLineOpt { $$ = $1; }
635 | "true" { $$ = $1; }
637 | "typeof" { $$ = $1; }
639 | "void" { $$ = $1; }
640 | "while" { $$ = $1; }
641 | "with" { $$ = $1; }
650 : Identifier_ { $$ = $1; }
653 | "typedef" { $$ = $1; }
656 | "implements" { $$ = $1; }
657 | "interface" { $$ = $1; }
658 | "package" { $$ = $1; }
659 | "private" { $$ = $1; }
660 | "protected" { $$ = $1; }
661 | "public" { $$ = $1; }
662 | "static" { $$ = $1; }
664 | "abstract" { $$ = $1; }
665 | "boolean" { $$ = $1; }
666 | "byte" { $$ = $1; }
667 | "char" { $$ = $1; }
668 | "double" { $$ = $1; }
669 | "final" { $$ = $1; }
670 | "float" { $$ = $1; }
671 | "goto" { $$ = $1; }
673 | "long" { $$ = $1; }
674 | "native" { $$ = $1; }
675 | "short" { $$ = $1; }
676 | "synchronized" { $$ = $1; }
677 | "throws" { $$ = $1; }
678 | "transient" { $$ = $1; }
679 | "volatile" { $$ = $1; }
681 // XXX: currently I only have this as Word
682 // | "let" { $$ = $1; }
684 | "yield" { $$ = $1; }
686 | "each" { $$ = $1; }
691 : Identifier { $$ = $1; }
696 /* 7.8 Literals {{{ */
698 : NullLiteral { $$ = $1; }
699 | ValueLiteral { $$ = $1; }
703 : BooleanLiteral { $$ = $1; }
704 | NumericLiteral { $$ = $1; }
705 | StringLiteral { $$ = $1; }
706 | RegularExpressionLiteral { $$ = $1; }
709 /* 7.8.1 Null Literals {{{ */
711 : "null" { $$ = $1; }
714 /* 7.8.2 Boolean Literals {{{ */
716 : "true" { $$ = $1; }
717 | "false" { $$ = $1; }
721 /* 7.9 Automatic Semicolon Insertion {{{ */
723 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
728 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
733 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
737 /* 11.1 Primary Expressions {{{ */
739 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
743 : Parenthetical { $$ = $1; }
748 : Identifier { $$ = CYNew CYVariable($1); }
752 : "this" { $$ = $1; }
753 | Variable { $$ = $1; }
754 | Literal { $$ = $1; }
755 | ArrayLiteral { $$ = $1; }
756 | ObjectLiteral { $$ = $1; }
757 | FunctionExpression { $$ = $1; }
758 | Parenthetical { $$ = $1; }
759 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
762 /* 11.1.4.1 Array Initialiser {{{ */
764 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
768 : AssignmentExpression { $$ = $1; }
772 : Element { $$ = $1; }
773 | LexSetRegExp { $$ = NULL; }
777 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
778 | Element { $$ = CYNew CYElement($1, NULL); }
782 : ElementList { $$ = $1; }
783 | LexSetRegExp { $$ = NULL; }
786 /* 11.1.4.2 Array Comprehension {{{ */
788 : "[" LexPushInOff AssignmentExpression ComprehensionForList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
792 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
793 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
796 ComprehensionForListOpt
797 : ComprehensionForList { $$ = $1; }
798 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
802 /* 11.1.5 Object Initialiser {{{ */
804 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
807 PropertyDefinitionList_
808 : "," PropertyDefinitionList { $$ = $2; }
809 | "," LexSetRegExp { $$ = NULL; }
813 PropertyDefinitionList
814 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
817 PropertyDefinitionListOpt
818 : PropertyDefinitionList { $$ = $1; }
819 | LexSetRegExp { $$ = NULL; }
823 // XXX: this should be IdentifierName
824 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
825 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
830 : IdentifierName { $$ = $1; }
831 | StringLiteral { $$ = $1; }
832 | NumericLiteral { $$ = $1; }
836 : LexSetRegExp PropertyName_ { $$ = $2; }
840 /* 11.2 Left-Hand-Side Expressions {{{ */
842 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
843 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
844 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
848 : MemberExpression { $$ = $1; }
849 //| "super" { $$ = $1; }
853 : LexSetRegExp PrimaryExpression { $$ = $2; }
854 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
855 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
859 : MemberExpression { $$ = $1; }
860 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
869 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
870 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
874 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
878 : "," ArgumentList { $$ = $2; }
883 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
887 : ArgumentList { $$ = $1; }
888 | LexSetRegExp { $$ = NULL; }
891 LeftHandSideExpression
892 : NewExpression { $$ = $1; }
893 | CallExpression { $$ = $1; }
896 /* 11.3 Postfix Expressions {{{ */
898 : %prec "" LeftHandSideExpression { $$ = $1; }
899 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
900 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
903 /* 11.4 Unary Operators {{{ */
905 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
906 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
907 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
908 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
909 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
910 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
911 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
912 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
913 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
914 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
915 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
919 : PostfixExpression { $$ = $1; }
920 | LexSetRegExp UnaryExpression_ { $$ = $2; }
923 /* 11.5 Multiplicative Operators {{{ */
924 MultiplicativeExpression
925 : UnaryExpression { $$ = $1; }
926 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
927 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
928 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
931 /* 11.6 Additive Operators {{{ */
933 : MultiplicativeExpression { $$ = $1; }
934 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
935 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
938 /* 11.7 Bitwise Shift Operators {{{ */
940 : AdditiveExpression { $$ = $1; }
941 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
942 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
943 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
946 /* 11.8 Relational Operators {{{ */
948 : ShiftExpression { $$ = $1; }
949 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
950 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
951 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
952 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
953 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
954 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
957 /* 11.9 Equality Operators {{{ */
959 : RelationalExpression { $$ = $1; }
960 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
961 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
962 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
963 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
966 /* 11.10 Binary Bitwise Operators {{{ */
968 : EqualityExpression { $$ = $1; }
969 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
973 : BitwiseANDExpression { $$ = $1; }
974 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
978 : BitwiseXORExpression { $$ = $1; }
979 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
982 /* 11.11 Binary Logical Operators {{{ */
984 : BitwiseORExpression { $$ = $1; }
985 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
989 : LogicalANDExpression { $$ = $1; }
990 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
993 /* 11.12 Conditional Operator ( ? : ) {{{ */
994 ConditionalExpression
995 : LogicalORExpression { $$ = $1; }
996 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
999 /* 11.13 Assignment Operators {{{ */
1000 AssignmentExpression
1001 : ConditionalExpression { $$ = $1; }
1002 | ArrowFunction { $$ = $1; }
1003 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1004 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1005 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1006 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1007 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1008 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1009 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1010 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1011 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1012 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1013 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1014 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1017 /* 11.14 Comma Operator {{{ */
1019 : "," Expression { $$ = $2; }
1020 | { $$ = CYNew CYCompound(); }
1024 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1028 : Expression { $$ = $1; }
1029 | LexSetRegExp { $$ = NULL; }
1033 /* 12 Statements {{{ */
1035 : Block { $$ = $1; }
1036 | VariableStatement { $$ = $1; }
1037 | EmptyStatement { $$ = $1; }
1038 | IfStatement { $$ = $1; }
1039 | BreakableStatement { $$ = $1; }
1040 | ContinueStatement { $$ = $1; }
1041 | BreakStatement { $$ = $1; }
1042 | ReturnStatement { $$ = $1; }
1043 | WithStatement { $$ = $1; }
1044 | LabelledStatement { $$ = $1; }
1045 | ThrowStatement { $$ = $1; }
1046 | TryStatement { $$ = $1; }
1047 | DebuggerStatement { $$ = $1; }
1051 : LexSetRegExp Statement__ { $$ = $2; }
1052 | ExpressionStatement { $$ = $1; }
1056 : LexSetStatement Statement_ { $$ = $2; }
1060 : FunctionDeclaration { $$ = $1; }
1061 | LexicalDeclaration { $$ = $1; }
1065 : LexSetRegExp Declaration__ { $$ = $2; }
1069 : LexSetStatement Declaration_ { $$ = $2; }
1073 : IterationStatement { $$ = $1; }
1074 | SwitchStatement { $$ = $1; }
1077 /* 12.1 Block {{{ */
1079 : BRACE StatementListOpt "}" { $$ = $2; }
1083 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1087 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1091 : StatementList { $$ = $1; }
1092 | LexSetStatement LexSetRegExp { $$ = NULL; }
1096 : Statement { $$ = $1; }
1097 | Declaration { $$ = $1; }
1101 /* 12.2 Declarations {{{ */
1103 : Identifier { $$ = $1; }
1110 // XXX: BindingPattern
1112 /* 12.2.1 Let and Const Declarations {{{ */
1114 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1122 /* 12.2.2 Variable Statement {{{ */
1124 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1127 VariableDeclarationList_
1128 : "," VariableDeclarationList { $$ = $2; }
1132 VariableDeclarationList
1133 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1137 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1138 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1142 : "=" AssignmentExpression { $$ = $2; }
1146 : Initialiser { $$ = $1; }
1150 /* 12.2.4 Destructuring Binding Patterns {{{ */
1154 : SingleNameBinding { $$ = $1; }
1158 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1162 /* 12.3 Empty Statement {{{ */
1164 : ";" { $$ = CYNew CYEmpty(); }
1167 /* 12.4 Expression Statement {{{ */
1169 : Expression Terminator { $$ = CYNew CYExpress($1); }
1172 /* 12.5 The if Statement {{{ */
1174 : "else" Statement { $$ = $2; }
1175 | %prec "if" { $$ = NULL; }
1179 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1183 /* 12.6.1 The do-while Statement {{{ */
1185 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1188 /* 12.6.2 The while Statement {{{ */
1190 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1193 /* 12.6.3 The for Statement {{{ */
1195 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1198 ForStatementInitialiser
1199 : ExpressionOpt { $$ = $1; }
1200 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1203 /* 12.6.4 The for-in and for-of Statements {{{ */
1205 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1206 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1209 ForInStatementInitialiser
1210 : LeftHandSideExpression { $$ = $1; }
1211 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1215 /* 12.7 The continue Statement {{{ */
1217 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1218 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1221 /* 12.8 The break Statement {{{ */
1223 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1224 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1227 /* 12.9 The return Statement {{{ */
1229 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1230 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1233 /* 12.10 The with Statement {{{ */
1235 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1239 /* 12.11 The switch Statement {{{ */
1241 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1245 : BRACE CaseClausesOpt "}" { $$ = $2; }
1249 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1253 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1254 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1259 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1262 /* 12.12 Labelled Statements {{{ */
1264 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1267 /* 12.13 The throw Statement {{{ */
1269 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1270 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1273 /* 12.14 The try Statement {{{ */
1275 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1279 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1284 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1288 /* 12.14 The debugger Statement {{{ */
1290 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1294 /* 13.1 Function Definitions {{{ */
1296 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1300 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1303 FormalParameterList_
1304 : "," FormalParameterList { $$ = $2; }
1309 // XXX: : FunctionRestParameter { $$ = $1; }
1310 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1313 FormalParameterListOpt
1314 : FormalParameterList
1318 /* XXX: FunctionRestParameter
1319 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1323 : BindingElement { $$ = $1; }
1327 : StatementListOpt { $$ = $1; }
1330 /* 13.2 Arrow Function Definitions {{{ */
1332 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1336 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1337 //| ParentheticalOpt { $$ = $1; }
1341 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1342 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1345 /* 14 Program {{{ */
1347 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1351 : StatementList { $$ = $1; }
1355 : ProgramBody { $$ = $1; }
1356 | LexSetStatement LexSetRegExp { $$ = NULL; }
1361 /* Cycript (Objective-C): Type Encoding {{{ */
1363 : IdentifierOpt { $$ = CYNew CYTypedIdentifier($1); }
1364 | "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1365 | SuffixedType "[" NumericLiteral "]" { CYSetLast($1->type_) = CYNew CYTypeArrayOf($3); $$ = $1; }
1369 : SuffixedType { $$ = $1; }
1370 | "const" PrefixedType { CYSetLast($2->type_) = CYNew CYTypeConstant(); $$ = $2; }
1371 | "*" PrefixedType { CYSetLast($2->type_) = CYNew CYTypePointerTo(); $$ = $2; }
1375 : Variable { $$ = $1; }
1376 | "void" { $$ = CYNew cy::Syntax::New(CYNew CYVariable(CYNew CYIdentifier("Type")), CYNew CYArgument(CYNew CYString("v"))); }
1380 : PrimitiveType { $$ = CYNew CYTypeVariable($1); }
1381 | "const" QualifiedType { $$ = CYNew CYTypeConstant($2); }
1385 : QualifiedType { $$ = $1; }
1386 | QualifiedType "*" { $$ = CYNew CYTypePointerTo($1); }
1387 | QualifiedType "const" { $$ = CYNew CYTypeConstant($1); }
1391 : QualifiedType PrefixedType { CYSetLast($2->type_) = $1; $$ = $2;}
1395 : TypedIdentifier { $$ = CYNew CYEncodedType($1->type_); }
1399 : AtEncode "(" EncodedType ")" { $$ = $3; }
1402 /* Cycript (Objective-C): @class Declaration {{{ */
1404 /* XXX: why the hell did I choose MemberExpression? */
1405 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1410 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1411 | LexSetRegExp { $$ = NULL; }
1415 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1419 : "+" { $$ = false; }
1420 | "-" { $$ = true; }
1424 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1429 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1432 MessageParameterList
1433 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1436 MessageParameterListOpt
1437 : MessageParameterList { $$ = $1; }
1442 : MessageParameterList { $$ = $1; }
1443 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1446 ClassMessageDeclaration
1447 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1450 ClassMessageDeclarationListOpt
1451 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1452 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1457 : Identifier { $$ = $1; }
1458 | "(" AssignmentExpression ")" { $$ = $2; }
1462 : ClassName { $$ = $1; }
1466 // XXX: this should be AssignmentExpressionNoRight
1468 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1472 : "," ClassProtocols { $$ = $2; }
1476 ClassProtocolListOpt
1477 : "<" ClassProtocols ">" { $$ = $2; }
1482 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1486 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1494 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1498 : ClassExpression { $$ = $1; }
1502 : ClassStatement { $$ = $1; }
1503 | CategoryStatement { $$ = $1; }
1506 /* Cycript (Objective-C): Send Message {{{ */
1508 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1513 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1514 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1518 : SelectorCall { $$ = $1; }
1519 | VariadicCall { $$ = $1; }
1523 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1527 : SelectorCall { $$ = $1; }
1528 | Word { $$ = CYNew CYArgument($1, NULL); }
1532 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1533 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1537 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1541 : SelectorExpression_ { $$ = $1; }
1542 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1545 SelectorExpressionOpt
1546 : SelectorExpression_ { $$ = $1; }
1551 : MessageExpression { $$ = $1; }
1552 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1555 /* Cycript (Objective-C): @import Directive {{{ */
1569 : LexSetStatement LexSetRegExp "@import" ImportPath { $$ = CYNew CYImport(); }
1572 /* Cycript (Objective-C): Boxed Expressions {{{ */
1574 : NullLiteral { $$ = $1; }
1575 | BooleanLiteral { $$ = $1; }
1576 | NumericLiteral { $$ = $1; }
1577 | StringLiteral { $$ = $1; }
1578 | ArrayLiteral { $$ = $1; }
1579 | ObjectLiteral { $$ = $1; }
1580 | Parenthetical { $$ = $1; }
1584 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1587 /* Cycript (Objective-C): Block Expressions {{{ */
1589 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1595 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1596 LeftHandSideExpression
1597 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1601 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1605 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1606 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1607 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1610 /* Cycript (C): auto Compatibility {{{ */
1615 /* Cycript (C): Lambda Expressions {{{ */
1617 : "," TypedParameterList { $$ = $2; }
1622 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1625 TypedParameterListOpt
1626 : TypedParameterList { $$ = $1; }
1631 : "[" LexPushInOff LexSetRegExp "=" "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" ModifiedType BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($13, $9, $16); }
1634 /* Cycript (C): Type Definitions {{{ */
1636 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1641 /* YUI: Documentation Comments {{{ */
1643 : Comment { $$ = $1; }
1648 /* Lexer State {{{ */
1650 : { driver.PushCondition(CYDriver::RegExpCondition); }
1654 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1658 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1662 : { driver.PopCondition(); }
1666 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1670 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1673 /* Virtual Tokens {{{ */
1680 /* 8.1 Context Keywords {{{ */
1682 : "namespace" { $$ = $1; }
1683 | "xml" { $$ = $1; }
1686 /* 8.3 XML Initialiser Input Elements {{{ */
1688 : XMLComment { $$ = $1; }
1689 | XMLCDATA { $$ = $1; }
1690 | XMLPI { $$ = $1; }
1694 /* 11.1 Primary Expressions {{{ */
1696 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1697 | XMLInitialiser { $$ = $1; }
1698 | XMLListInitialiser { $$ = $1; }
1702 : AttributeIdentifier { $$ = $1; }
1703 | QualifiedIdentifier { $$ = $1; }
1704 | WildcardIdentifier { $$ = $1; }
1707 /* 11.1.1 Attribute Identifiers {{{ */
1709 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1713 : PropertySelector { $$ = $1; }
1714 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1718 : Identifier { $$ = CYNew CYSelector($1); }
1719 | WildcardIdentifier { $$ = $1; }
1722 /* 11.1.2 Qualified Identifiers {{{ */
1723 QualifiedIdentifier_
1724 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1725 | QualifiedIdentifier { $$ = $1; }
1729 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1732 /* 11.1.3 Wildcard Identifiers {{{ */
1734 : "*" { $$ = CYNew CYWildcard(); }
1737 /* 11.1.4 XML Initialiser {{{ */
1739 : XMLMarkup { $$ = $1; }
1740 | XMLElement { $$ = $1; }
1744 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1745 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1749 : LexPushXMLTag XMLTagName XMLAttributes
1753 : BRACE LexPushRegExp Expression LexPop "}"
1762 : XMLAttributes_ XMLAttribute
1767 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1768 | XMLAttributes_ XMLWhitespaceOpt
1777 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1781 : XMLExpression XMLElementContentOpt
1782 | XMLMarkup XMLElementContentOpt
1783 | XMLText XMLElementContentOpt
1784 | XMLElement XMLElementContentOpt
1787 XMLElementContentOpt
1792 /* 11.1.5 XMLList Initialiser {{{ */
1794 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1798 /* 11.2 Left-Hand-Side Expressions {{{ */
1800 : Identifier { $$ = $1; }
1801 | PropertyIdentifier { $$ = $1; }
1805 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1806 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1807 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1810 /* 12.1 The default xml namespace Statement {{{ */
1811 /* XXX: DefaultXMLNamespaceStatement
1812 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1816 : DefaultXMLNamespaceStatement { $$ = $1; }
1821 /* JavaScript 1.7: Array Comprehensions {{{ */
1823 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1827 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1828 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1832 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1835 ComprehensionListOpt
1836 : ComprehensionList { $$ = $1; }
1837 | IfComprehension { $$ = $1; }
1842 : "[" LexPushInOff AssignmentExpression ComprehensionList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
1845 /* JavaScript 1.7: for each {{{ */
1847 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1850 /* JavaScript 1.7: let Statements {{{ */
1852 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1860 /* JavaScript FTW: Ruby Blocks {{{ */
1861 RubyProcParameterList_
1862 : "," RubyProcParameterList { $$ = $2; }
1866 RubyProcParameterList
1867 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1872 : "|" RubyProcParameterList "|" { $$ = $2; }
1873 | "||" { $$ = NULL; }
1876 RubyProcParametersOpt
1877 : RubyProcParameters
1882 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1886 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1890 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }