1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2014 Jay Freeman (saurik)
5 /* GNU Affero General Public License, Version 3 {{{ */
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. 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_;
79 CYProperty *property_;
80 CYPropertyName *propertyName_;
81 CYRubyProc *rubyProc_;
82 CYStatement *statement_;
89 CYTypeModifier *modifier_;
90 CYTypeSpecifier *specifier_;
91 CYTypedIdentifier *typedIdentifier_;
92 CYTypedParameter *typedParameter_;
96 CYClassName *className_;
99 CYMessageParameter *messageParameter_;
100 CYProtocol *protocol_;
101 CYSelectorPart *selector_;
105 CYAttribute *attribute_;
106 CYPropertyIdentifier *propertyIdentifier_;
107 CYSelector *selector_;
112 #define YYSTYPE YYSTYPE
114 @if Bison24 %code provides {
115 int cylex(YYSTYPE *, cy::location *, void *);
128 @if Bison23 %skeleton "lalr1.cc"
129 @if Bison24 %language "C++"
132 @$.begin.filename = @$.end.filename = &driver.filename_;
143 %parse-param { CYDriver &driver }
144 %lex-param { void *cyscanner }
146 /* Token Declarations {{{ */
152 %token XMLAttributeValue
154 %token XMLTagCharacters
160 %token LeftRight "<>"
161 %token LeftSlashRight "</>"
163 %token SlashRight "/>"
164 %token LeftSlash "</"
166 %token ColonColon "::"
167 %token PeriodPeriod ".."
170 @begin E4X ObjectiveC
176 %token AmpersandAmpersand "&&"
177 %token AmpersandEqual "&="
179 %token CarrotEqual "^="
181 %token EqualEqual "=="
182 %token EqualEqualEqual "==="
183 %token EqualRight "=>"
184 %token Exclamation "!"
185 %token ExclamationEqual "!="
186 %token ExclamationEqualEqual "!=="
188 %token HyphenEqual "-="
189 %token HyphenHyphen "--"
190 %token HyphenHyphen_ "\n--"
191 %token HyphenRight "->"
193 %token LeftEqual "<="
195 %token LeftLeftEqual "<<="
197 %token PercentEqual "%="
199 %token PeriodPeriodPeriod "..."
201 %token PipeEqual "|="
204 %token PlusEqual "+="
206 %token PlusPlus_ "\n++"
208 %token RightEqual ">="
209 %token RightRight ">>"
210 %token RightRightEqual ">>="
211 %token RightRightRight ">>>"
212 %token RightRightRightEqual ">>>="
214 %token SlashEqual "/="
216 %token StarEqual "*="
225 %token <comment_> Comment
228 %token CloseParen ")"
231 %token OpenBrace_ "\n{"
232 %token OpenBrace__ ";{"
233 %token CloseBrace "}"
235 %token OpenBracket "["
236 %token CloseBracket "]"
238 %token AtError "@error"
241 %token AtClass "@class"
245 %token <identifier_> Typedef "typedef"
246 %token <identifier_> Unsigned "unsigned"
247 %token <identifier_> Signed "signed"
251 %token AtEncode "@encode"
255 %token AtImplementation "@implementation"
256 %token AtImplementation_ ";@implementation"
257 %token AtImport "@import"
259 %token AtSelector "@selector"
260 %token <identifier_> Yes "YES"
261 %token <identifier_> No "NO"
264 %token <false_> False "false"
265 %token <null_> Null "null"
266 %token <true_> True "true"
268 // ES3/ES5/WIE/JSC Reserved
269 %token <word_> Auto "auto"
270 %token <word_> Break "break"
271 %token <word_> Case "case"
272 %token <word_> Catch "catch"
273 %token <word_> Continue "continue"
274 %token <word_> Default "default"
275 %token <word_> Delete "delete"
276 %token <word_> Do "do"
277 %token <word_> Else "else"
278 %token <word_> Finally "finally"
279 %token <word_> For "for"
280 %token <word_> Function "function"
281 %token <word_> Function_ ";function"
282 %token <word_> If "if"
283 %token <word_> In "in"
284 %token <word_> In_ "!in"
285 %token <word_> InstanceOf "instanceof"
286 %token <word_> New "new"
287 %token <word_> Return "return"
288 %token <word_> Switch "switch"
289 %token <this_> This "this"
290 %token <word_> Throw "throw"
291 %token <word_> Try "try"
292 %token <word_> TypeOf "typeof"
293 %token <word_> Var "var"
294 %token <word_> Void "void"
295 %token <word_> While "while"
296 %token <word_> With "with"
298 // ES3/IE6 Future, ES5/JSC Reserved
299 %token <word_> Debugger "debugger"
301 // ES3/ES5/IE6 Future, JSC Reserved
302 %token <word_> Const "const"
304 // ES3/ES5/IE6/JSC Future
305 %token <word_> Class "class"
306 %token <word_> Enum "enum"
307 %token <word_> Export "export"
308 %token <word_> Extends "extends"
309 %token <word_> Import "import"
310 %token <word_> Super "super"
312 // ES3 Future, ES5 Strict Future
313 %token <identifier_> Implements "implements"
314 %token <identifier_> Interface "interface"
315 %token <identifier_> Package "package"
316 %token <identifier_> Private "private"
317 %token <identifier_> Protected "protected"
318 %token <identifier_> Public "public"
319 %token <identifier_> Static "static"
322 %token <identifier_> Abstract "abstract"
323 %token <identifier_> Boolean "boolean"
324 %token <identifier_> Byte "byte"
325 %token <identifier_> Char "char"
326 %token <identifier_> Double "double"
327 %token <identifier_> Final "final"
328 %token <identifier_> Float "float"
329 %token <identifier_> Goto "goto"
330 %token <identifier_> Int "int"
331 %token <identifier_> Long "long"
332 %token <identifier_> Native "native"
333 %token <identifier_> Short "short"
334 %token <identifier_> Synchronized "synchronized"
335 %token <identifier_> Throws "throws"
336 %token <identifier_> Transient "transient"
337 %token <identifier_> Volatile "volatile"
340 %token <identifier_> Let "let"
341 %token <identifier_> Yield "yield"
344 %token <identifier_> Each "each"
345 %token <identifier_> Of "of"
349 %token <identifier_> Namespace "namespace"
350 %token <identifier_> XML "xml"
355 %token <identifier_> Identifier_
356 %token <number_> NumericLiteral
357 %token <string_> StringLiteral
358 %token <literal_> RegularExpressionLiteral
360 %type <expression_> AdditiveExpression
361 %type <argument_> ArgumentList_
362 %type <argument_> ArgumentList
363 %type <argument_> ArgumentListOpt
364 %type <argument_> Arguments
365 %type <expression_> ArrayComprehension
366 %type <expression_> ArrayInitialiser
367 %type <literal_> ArrayLiteral
368 %type <expression_> ArrowFunction
369 %type <functionParameter_> ArrowParameters
370 %type <expression_> AssignmentExpression
371 %type <identifier_> Binding
372 %type <identifier_> BindingIdentifier
373 %type <expression_> BitwiseANDExpression
374 %type <statement_> Block_
375 %type <statement_> Block
376 %type <boolean_> BooleanLiteral
377 %type <declaration_> BindingElement
378 %type <expression_> BitwiseORExpression
379 %type <expression_> BitwiseXORExpression
380 %type <statement_> BreakStatement
381 %type <statement_> BreakableStatement
382 %type <expression_> CallExpression_
383 %type <expression_> CallExpression
384 %type <clause_> CaseBlock
385 %type <clause_> CaseClause
386 %type <clause_> CaseClausesOpt
387 %type <catch_> CatchOpt
388 %type <expression_> Comprehension
389 %type <comprehension_> ComprehensionFor
390 %type <comprehension_> ComprehensionIf
391 %type <comprehension_> ComprehensionTail
392 %type <expression_> ConditionalExpression
393 %type <statement_> ContinueStatement
394 %type <statement_> ConciseBody
395 %type <statement_> DebuggerStatement
396 %type <statement_> Declaration__
397 %type <statement_> Declaration_
398 %type <statement_> Declaration
399 %type <clause_> DefaultClause
400 %type <expression_> Element
401 %type <expression_> ElementOpt
402 %type <element_> ElementList
403 %type <element_> ElementListOpt
404 %type <statement_> ElseStatementOpt
405 %type <statement_> EmptyStatement
406 %type <expression_> EqualityExpression
407 %type <compound_> Expression_
408 %type <compound_> Expression
409 %type <expression_> ExpressionOpt
410 %type <statement_> ExpressionStatement
411 %type <finally_> FinallyOpt
412 %type <for_> ForStatementInitialiser
413 %type <forin_> ForInStatementInitialiser
414 %type <declaration_> FormalParameter
415 %type <functionParameter_> FormalParameterList_
416 %type <functionParameter_> FormalParameterList
417 %type <functionParameter_> FormalParameterListOpt
418 %type <statement_> FunctionBody
419 %type <statement_> FunctionDeclaration
420 %type <expression_> FunctionExpression
421 %type <identifier_> Identifier
422 %type <identifier_> IdentifierOpt
423 %type <identifier_> IdentifierType
424 %type <word_> IdentifierName
425 %type <statement_> IfStatement
426 %type <expression_> Initialiser
427 %type <expression_> InitialiserOpt
428 %type <statement_> IterationStatement
429 %type <statement_> LabelledStatement
430 %type <expression_> LeftHandSideExpression
431 %type <statement_> LetStatement
432 %type <statement_> LexicalDeclaration
433 %type <literal_> Literal
434 %type <literal_> ValueLiteral
435 %type <expression_> LogicalANDExpression
436 %type <expression_> LogicalORExpression
437 %type <member_> MemberAccess
438 %type <expression_> MemberExpression_
439 %type <expression_> MemberExpression
440 %type <module_> Module
441 %type <expression_> MultiplicativeExpression
442 %type <expression_> NewExpression
443 %type <null_> NullLiteral
444 %type <literal_> ObjectLiteral
445 %type <compound_> Parenthetical
446 %type <compound_> ParentheticalOpt
447 %type <expression_> PostfixExpression
448 %type <expression_> PrimaryExpression
449 %type <statement_> Program
450 %type <statement_> ProgramBody
451 %type <statement_> ProgramBodyOpt
452 %type <propertyName_> PropertyName_
453 %type <propertyName_> PropertyName
454 %type <property_> PropertyDefinition
455 %type <property_> PropertyDefinitionList_
456 %type <property_> PropertyDefinitionList
457 %type <property_> PropertyDefinitionListOpt
458 %type <expression_> RelationalExpression
459 %type <statement_> ReturnStatement
460 %type <rubyProc_> RubyProcExpression
461 %type <functionParameter_> RubyProcParameterList_
462 %type <functionParameter_> RubyProcParameterList
463 %type <functionParameter_> RubyProcParameters
464 %type <functionParameter_> RubyProcParametersOpt
465 %type <expression_> ShiftExpression
466 %type <declaration_> SingleNameBinding
467 %type <statement_> Statement__
468 %type <statement_> Statement_
469 %type <statement_> Statement
470 %type <statement_> StatementList
471 %type <statement_> StatementListOpt
472 %type <statement_> StatementListItem
473 %type <statement_> SwitchStatement
474 %type <statement_> ThrowStatement
475 %type <statement_> TryStatement
476 %type <expression_> UnaryExpression_
477 %type <expression_> UnaryExpression
478 %type <declaration_> VariableDeclaration
479 %type <declarations_> VariableDeclarationList_
480 %type <declarations_> VariableDeclarationList
481 %type <statement_> VariableStatement
482 %type <statement_> WithStatement
484 %type <word_> WordOpt
485 %type <expression_> Variable
488 %type <typedIdentifier_> ArrayedType
489 %type <modifier_> FunctionedType
490 %type <specifier_> IntegerType
491 %type <specifier_> IntegerTypeOpt
492 %type <typedIdentifier_> PrefixedType
493 %type <specifier_> PrimitiveType
494 %type <typedIdentifier_> TypeParenthetical
495 %type <typedIdentifier_> TypeSignifier
496 %type <typedIdentifier_> SuffixedType
497 %type <modifier_> TypeQualifierLeft
498 %type <typedIdentifier_> TypeQualifierRight
499 %type <typedIdentifier_> TypedIdentifier
500 %type <typedParameter_> TypedParameterList_
501 %type <typedParameter_> TypedParameterList
502 %type <typedParameter_> TypedParameterListOpt
506 %type <expression_> BoxableExpression
507 %type <statement_> CategoryStatement
508 %type <expression_> ClassExpression
509 %type <field_> ClassFieldListOpt
510 %type <field_> ClassFields
511 %type <statement_> ClassStatement
512 %type <expression_> ClassSuperOpt
513 %type <message_> ClassMessageDeclaration
514 %type <message_> ClassMessageDeclarationListOpt
515 %type <className_> ClassName
516 %type <className_> ClassNameOpt
517 %type <protocol_> ClassProtocolListOpt
518 %type <protocol_> ClassProtocols
519 %type <protocol_> ClassProtocolsOpt
520 %type <expression_> MessageExpression
521 %type <messageParameter_> MessageParameter
522 %type <messageParameter_> MessageParameters
523 %type <messageParameter_> MessageParameterList
524 %type <messageParameter_> MessageParameterListOpt
525 %type <bool_> MessageScope
526 %type <typedIdentifier_> ModifiedType
527 %type <argument_> SelectorCall_
528 %type <argument_> SelectorCall
529 %type <selector_> SelectorExpression_
530 %type <selector_> SelectorExpression
531 %type <selector_> SelectorExpressionOpt
532 %type <argument_> SelectorList
533 %type <word_> SelectorWordOpt
534 %type <typedIdentifier_> TypeOpt
535 %type <argument_> VariadicCall
539 %type <propertyIdentifier_> PropertyIdentifier_
540 %type <selector_> PropertySelector_
541 %type <selector_> PropertySelector
542 %type <identifier_> QualifiedIdentifier_
543 %type <identifier_> QualifiedIdentifier
544 %type <identifier_> WildcardIdentifier
545 %type <identifier_> XMLComment
546 %type <identifier_> XMLCDATA
547 %type <identifier_> XMLElement
548 %type <identifier_> XMLElementContent
549 %type <identifier_> XMLMarkup
550 %type <identifier_> XMLPI
552 %type <attribute_> AttributeIdentifier
553 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
554 %type <expression_> PropertyIdentifier
555 %type <expression_> XMLListInitialiser
556 %type <expression_> XMLInitialiser
559 /* Token Priorities {{{ */
571 /* Lexer State {{{ */
573 : { driver.in_.push(true); }
577 : { driver.in_.push(false); }
581 : { driver.in_.pop(); }
585 : { driver.SetCondition(CYDriver::RegExpCondition); }
589 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
593 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
596 LexNoAtImplementation :
598 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
603 : LexNoBrace LexNoFunction LexNoAtImplementation
606 /* Virtual Tokens {{{ */
617 /* 7.6 Identifier Names and Identifiers {{{ */
628 : Identifier { $$ = $1; }
629 | "auto" { $$ = $1; }
630 | "break" NewLineOpt { $$ = $1; }
631 | "case" { $$ = $1; }
632 | "catch" { $$ = $1; }
633 | "class" { $$ = $1; }
634 | "const" { $$ = $1; }
635 | "continue" NewLineOpt { $$ = $1; }
636 | "debugger" { $$ = $1; }
637 | "default" { $$ = $1; }
638 | "delete" { $$ = $1; }
640 | "else" { $$ = $1; }
641 | "enum" { $$ = $1; }
642 | "export" { $$ = $1; }
643 | "extends" { $$ = $1; }
644 | "false" { $$ = $1; }
645 | "finally" { $$ = $1; }
646 /* XXX: | "for" { $$ = $1; } */
647 | "function" { $$ = $1; }
649 | "import" { $$ = $1; }
650 /* XXX: | "in" { $$ = $1; } */
652 /* XXX: | "instanceof" { $$ = $1; } */
654 // XXX: as it currently is not an Identifier
658 | "null" { $$ = $1; }
659 | "return" NewLineOpt { $$ = $1; }
660 | "super" { $$ = $1; }
661 | "switch" { $$ = $1; }
662 | "this" { $$ = $1; }
663 | "throw" NewLineOpt { $$ = $1; }
664 | "true" { $$ = $1; }
666 | "typeof" { $$ = $1; }
668 | "void" { $$ = $1; }
669 | "while" { $$ = $1; }
670 | "with" { $$ = $1; }
679 : Identifier_ { $$ = $1; }
681 | "implements" { $$ = $1; }
682 | "interface" { $$ = $1; }
683 | "package" { $$ = $1; }
684 | "private" { $$ = $1; }
685 | "protected" { $$ = $1; }
686 | "public" { $$ = $1; }
687 | "static" { $$ = $1; }
689 | "abstract" { $$ = $1; }
690 | "boolean" { $$ = $1; }
691 | "byte" { $$ = $1; }
692 | "double" { $$ = $1; }
693 | "final" { $$ = $1; }
694 | "float" { $$ = $1; }
695 | "goto" { $$ = $1; }
696 | "native" { $$ = $1; }
697 | "synchronized" { $$ = $1; }
698 | "throws" { $$ = $1; }
699 | "transient" { $$ = $1; }
701 // XXX: currently I only have this as Word
702 // | "let" { $$ = $1; }
704 | "yield" { $$ = $1; }
706 | "each" { $$ = $1; }
712 | "char" { $$ = $1; }
714 | "long" { $$ = $1; }
715 | "short" { $$ = $1; }
716 | "volatile" { $$ = $1; }
718 | "typedef" { $$ = $1; }
719 | "unsigned" { $$ = $1; }
720 | "signed" { $$ = $1; }
729 : Identifier { $$ = $1; }
734 /* 7.8 Literals {{{ */
736 : NullLiteral { $$ = $1; }
737 | ValueLiteral { $$ = $1; }
741 : BooleanLiteral { $$ = $1; }
742 | NumericLiteral { $$ = $1; }
743 | StringLiteral { $$ = $1; }
744 | RegularExpressionLiteral { $$ = $1; }
747 /* 7.8.1 Null Literals {{{ */
749 : "null" { $$ = $1; }
752 /* 7.8.2 Boolean Literals {{{ */
754 : "true" { $$ = $1; }
755 | "false" { $$ = $1; }
759 /* 7.9 Automatic Semicolon Insertion {{{ */
761 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
766 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
771 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
775 /* 11.1 Primary Expressions {{{ */
777 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
781 : Parenthetical { $$ = $1; }
786 : Identifier { $$ = CYNew CYVariable($1); }
790 : "this" { $$ = $1; }
791 | Variable { $$ = $1; }
792 | Literal { $$ = $1; }
793 | ArrayInitialiser { $$ = $1; }
794 | ObjectLiteral { $$ = $1; }
795 | Parenthetical { $$ = $1; }
796 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
799 /* 11.1.4 Array Initializer {{{ */
801 : ArrayLiteral { $$ = $1; }
802 | ArrayComprehension { $$ = $1; }
805 /* 11.1.4.1 Array Literal {{{ */
807 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
811 : AssignmentExpression { $$ = $1; }
815 : Element { $$ = $1; }
816 | LexSetRegExp { $$ = NULL; }
820 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
821 | Element { $$ = CYNew CYElement($1, NULL); }
825 : ElementList { $$ = $1; }
826 | LexSetRegExp { $$ = NULL; }
829 /* 11.1.4.2 Array Comprehension {{{ */
831 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
835 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
840 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
841 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
845 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
849 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
852 /* 11.1.5 Object Initialiser {{{ */
854 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
857 PropertyDefinitionList_
858 : "," PropertyDefinitionList { $$ = $2; }
859 | "," LexSetRegExp { $$ = NULL; }
863 PropertyDefinitionList
864 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
867 PropertyDefinitionListOpt
868 : PropertyDefinitionList { $$ = $1; }
869 | LexSetRegExp { $$ = NULL; }
873 // XXX: this should be IdentifierName
874 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
875 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
880 : IdentifierName { $$ = $1; }
881 | StringLiteral { $$ = $1; }
882 | NumericLiteral { $$ = $1; }
886 : LexSetRegExp PropertyName_ { $$ = $2; }
890 /* 11.2 Left-Hand-Side Expressions {{{ */
892 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
893 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
894 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
898 : MemberExpression { $$ = $1; }
899 //| "super" { $$ = $1; }
903 : LexSetRegExp PrimaryExpression { $$ = $2; }
904 | LexSetRegExp FunctionExpression { $$ = $2; }
905 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
906 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
910 : MemberExpression { $$ = $1; }
911 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
920 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
921 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
925 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
929 : "," ArgumentList { $$ = $2; }
934 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
938 : ArgumentList { $$ = $1; }
939 | LexSetRegExp { $$ = NULL; }
942 LeftHandSideExpression
943 : NewExpression { $$ = $1; }
944 | CallExpression { $$ = $1; }
947 /* 11.3 Postfix Expressions {{{ */
949 : %prec "" LeftHandSideExpression { $$ = $1; }
950 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
951 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
954 /* 11.4 Unary Operators {{{ */
956 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
957 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
958 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
959 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
960 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
961 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
962 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
963 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
964 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
965 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
966 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
970 : PostfixExpression { $$ = $1; }
971 | LexSetRegExp UnaryExpression_ { $$ = $2; }
974 /* 11.5 Multiplicative Operators {{{ */
975 MultiplicativeExpression
976 : UnaryExpression { $$ = $1; }
977 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
978 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
979 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
982 /* 11.6 Additive Operators {{{ */
984 : MultiplicativeExpression { $$ = $1; }
985 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
986 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
989 /* 11.7 Bitwise Shift Operators {{{ */
991 : AdditiveExpression { $$ = $1; }
992 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
993 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
994 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
997 /* 11.8 Relational Operators {{{ */
999 : ShiftExpression { $$ = $1; }
1000 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
1001 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
1002 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
1003 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
1004 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
1005 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
1008 /* 11.9 Equality Operators {{{ */
1010 : RelationalExpression { $$ = $1; }
1011 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1012 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1013 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1014 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1017 /* 11.10 Binary Bitwise Operators {{{ */
1018 BitwiseANDExpression
1019 : EqualityExpression { $$ = $1; }
1020 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1023 BitwiseXORExpression
1024 : BitwiseANDExpression { $$ = $1; }
1025 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1029 : BitwiseXORExpression { $$ = $1; }
1030 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1033 /* 11.11 Binary Logical Operators {{{ */
1034 LogicalANDExpression
1035 : BitwiseORExpression { $$ = $1; }
1036 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1040 : LogicalANDExpression { $$ = $1; }
1041 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1044 /* 11.12 Conditional Operator ( ? : ) {{{ */
1045 ConditionalExpression
1046 : LogicalORExpression { $$ = $1; }
1047 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1048 | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1051 /* 11.13 Assignment Operators {{{ */
1052 AssignmentExpression
1053 : ConditionalExpression { $$ = $1; }
1054 | ArrowFunction { $$ = $1; }
1055 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1056 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1057 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1058 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1059 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1060 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1061 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1062 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1063 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1064 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1065 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1066 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1069 /* 11.14 Comma Operator {{{ */
1071 : "," Expression { $$ = $2; }
1076 : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); }
1080 : Expression { $$ = $1; }
1081 | LexSetRegExp { $$ = NULL; }
1085 /* 12 Statements {{{ */
1087 : Block { $$ = $1; }
1088 | VariableStatement { $$ = $1; }
1089 | EmptyStatement { $$ = $1; }
1090 | IfStatement { $$ = $1; }
1091 | BreakableStatement { $$ = $1; }
1092 | ContinueStatement { $$ = $1; }
1093 | BreakStatement { $$ = $1; }
1094 | ReturnStatement { $$ = $1; }
1095 | WithStatement { $$ = $1; }
1096 | LabelledStatement { $$ = $1; }
1097 | ThrowStatement { $$ = $1; }
1098 | TryStatement { $$ = $1; }
1099 | DebuggerStatement { $$ = $1; }
1103 : LexSetRegExp Statement__ { $$ = $2; }
1104 | ExpressionStatement { $$ = $1; }
1108 : LexSetStatement Statement_ { $$ = $2; }
1112 : FunctionDeclaration { $$ = $1; }
1113 | LexicalDeclaration { $$ = $1; }
1117 : LexSetRegExp Declaration__ { $$ = $2; }
1121 : LexSetStatement Declaration_ { $$ = $2; }
1125 : IterationStatement { $$ = $1; }
1126 | SwitchStatement { $$ = $1; }
1129 /* 12.1 Block {{{ */
1131 : BRACE StatementListOpt "}" { $$ = $2; }
1135 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1139 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1143 : StatementList { $$ = $1; }
1144 | LexSetStatement LexSetRegExp { $$ = NULL; }
1148 : Statement { $$ = $1; }
1149 | Declaration { $$ = $1; }
1153 /* 12.2 Declarations {{{ */
1155 : Identifier { $$ = $1; }
1162 // XXX: BindingPattern
1164 /* 12.2.1 Let and Const Declarations {{{ */
1166 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1174 /* 12.2.2 Variable Statement {{{ */
1176 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1179 VariableDeclarationList_
1180 : "," VariableDeclarationList { $$ = $2; }
1184 VariableDeclarationList
1185 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1189 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1190 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1194 : "=" AssignmentExpression { $$ = $2; }
1198 : Initialiser { $$ = $1; }
1202 /* 12.2.4 Destructuring Binding Patterns {{{ */
1206 : SingleNameBinding { $$ = $1; }
1210 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1214 /* 12.3 Empty Statement {{{ */
1216 : ";" { $$ = CYNew CYEmpty(); }
1219 /* 12.4 Expression Statement {{{ */
1221 : Expression Terminator { $$ = CYNew CYExpress($1); }
1224 /* 12.5 The if Statement {{{ */
1226 : "else" Statement { $$ = $2; }
1227 | %prec "if" { $$ = NULL; }
1231 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1235 /* 12.6.1 The do-while Statement {{{ */
1237 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1240 /* 12.6.2 The while Statement {{{ */
1242 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1245 /* 12.6.3 The for Statement {{{ */
1247 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1250 ForStatementInitialiser
1251 : ExpressionOpt { $$ = $1; }
1252 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1255 /* 12.6.4 The for-in and for-of Statements {{{ */
1257 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1258 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1261 ForInStatementInitialiser
1262 : LeftHandSideExpression { $$ = $1; }
1263 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1267 /* 12.7 The continue Statement {{{ */
1269 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1270 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1273 /* 12.8 The break Statement {{{ */
1275 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1276 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1279 /* 12.9 The return Statement {{{ */
1281 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1282 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1285 /* 12.10 The with Statement {{{ */
1287 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1291 /* 12.11 The switch Statement {{{ */
1293 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1297 : BRACE CaseClausesOpt "}" { $$ = $2; }
1301 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1305 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1306 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1311 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1314 /* 12.12 Labelled Statements {{{ */
1316 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1319 /* 12.13 The throw Statement {{{ */
1321 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1322 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1325 /* 12.14 The try Statement {{{ */
1327 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1331 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1336 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1340 /* 12.14 The debugger Statement {{{ */
1342 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1346 /* 13.1 Function Definitions {{{ */
1348 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1352 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1355 FormalParameterList_
1356 : "," FormalParameterList { $$ = $2; }
1361 // XXX: : FunctionRestParameter { $$ = $1; }
1362 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1365 FormalParameterListOpt
1366 : FormalParameterList
1370 /* XXX: FunctionRestParameter
1371 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1375 : BindingElement { $$ = $1; }
1379 : StatementListOpt { $$ = $1; }
1382 /* 13.2 Arrow Function Definitions {{{ */
1384 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1388 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1389 //| ParentheticalOpt { $$ = $1; }
1393 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1394 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1397 /* 14 Program {{{ */
1399 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1403 : StatementList { $$ = $1; }
1407 : ProgramBody { $$ = $1; }
1408 | LexSetStatement LexSetRegExp { $$ = NULL; }
1413 /* Cycript (C): Type Encoding {{{ */
1415 : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1419 : IdentifierType { $$ = CYNew CYTypedIdentifier($1); }
1420 | TypeParenthetical { $$ = $1; }
1424 : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1425 | TypeSignifier { $$ = $1; }
1426 | { $$ = CYNew CYTypedIdentifier(); }
1430 : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); }
1434 : ArrayedType { $$ = $1; }
1435 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1436 | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1437 | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1441 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1446 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1447 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1451 : PrefixedType { $$ = $1; }
1452 | SuffixedType { $$ = $1; }
1453 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1454 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1458 : "int" { $$ = CYNew CYTypeVariable("int"); }
1459 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1460 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1461 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1462 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1466 : IntegerType { $$ = $1; }
1467 | { $$ = CYNew CYTypeVariable("int"); }
1471 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1472 | IntegerType { $$ = $1; }
1473 | "void" { $$ = CYNew CYTypeVoid(); }
1474 | "char" { $$ = CYNew CYTypeVariable("char"); }
1475 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1476 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1480 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1484 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1490 /* Cycript (Objective-C): @class Declaration {{{ */
1492 /* XXX: why the hell did I choose MemberExpression? */
1493 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1498 : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $3); }
1499 | LexSetRegExp { $$ = NULL; }
1503 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1507 : "+" { $$ = false; }
1508 | "-" { $$ = true; }
1512 : "(" LexSetRegExp TypedIdentifier ")" { $$ = $3; }
1517 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1520 MessageParameterList
1521 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1524 MessageParameterListOpt
1525 : MessageParameterList { $$ = $1; }
1530 : MessageParameterList { $$ = $1; }
1531 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1534 ClassMessageDeclaration
1535 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1538 ClassMessageDeclarationListOpt
1539 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1540 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1545 : Identifier { $$ = $1; }
1546 | "(" AssignmentExpression ")" { $$ = $2; }
1550 : ClassName { $$ = $1; }
1554 // XXX: this should be AssignmentExpressionNoRight
1556 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1560 : "," ClassProtocols { $$ = $2; }
1564 ClassProtocolListOpt
1565 : "<" ClassProtocols ">" { $$ = $2; }
1570 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1574 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1582 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1586 : ClassExpression { $$ = $1; }
1590 : ClassStatement { $$ = $1; }
1591 | CategoryStatement { $$ = $1; }
1594 /* Cycript (Objective-C): Send Message {{{ */
1596 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1601 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1602 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1606 : SelectorCall { $$ = $1; }
1607 | VariadicCall { $$ = $1; }
1611 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1615 : SelectorCall { $$ = $1; }
1616 | Word { $$ = CYNew CYArgument($1, NULL); }
1620 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1621 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1625 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1629 : SelectorExpression_ { $$ = $1; }
1630 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1633 SelectorExpressionOpt
1634 : SelectorExpression_ { $$ = $1; }
1639 : MessageExpression { $$ = $1; }
1640 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1645 /* Cycript: @import Directive {{{ */
1647 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1648 | Word { $$ = CYNew CYModule($1); }
1652 : "@import" Module { $$ = CYNew CYImport($2); }
1657 /* Cycript (Objective-C): Boxed Expressions {{{ */
1659 : NullLiteral { $$ = $1; }
1660 | BooleanLiteral { $$ = $1; }
1661 | NumericLiteral { $$ = $1; }
1662 | StringLiteral { $$ = $1; }
1663 | ArrayLiteral { $$ = $1; }
1664 | ObjectLiteral { $$ = $1; }
1665 | Parenthetical { $$ = $1; }
1666 | "YES" { $$ = CYNew CYTrue(); }
1667 | "NO" { $$ = CYNew CYFalse(); }
1671 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1674 /* Cycript (Objective-C): Block Expressions {{{ */
1676 : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->specifier_ = $2; $$->modifier_ = $1; }
1677 | ModifiedType "*" { $$ = $1; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1681 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1684 /* Cycript (Objective-C): Instance Literals {{{ */
1686 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
1692 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1693 LeftHandSideExpression
1694 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1698 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1702 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1703 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1704 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1707 /* Cycript (C): auto Compatibility {{{ */
1712 /* Cycript (C): Lambda Expressions {{{ */
1714 : "," TypedParameterList { $$ = $2; }
1719 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1722 TypedParameterListOpt
1723 : TypedParameterList { $$ = $1; }
1728 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1731 /* Cycript (C): Type Definitions {{{ */
1733 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1738 /* YUI: Documentation Comments {{{ */
1740 : Comment { $$ = $1; }
1745 /* Lexer State {{{ */
1747 : { driver.PushCondition(CYDriver::RegExpCondition); }
1751 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1755 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1759 : { driver.PopCondition(); }
1763 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1767 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1770 /* Virtual Tokens {{{ */
1777 /* 8.1 Context Keywords {{{ */
1779 : "namespace" { $$ = $1; }
1780 | "xml" { $$ = $1; }
1783 /* 8.3 XML Initialiser Input Elements {{{ */
1785 : XMLComment { $$ = $1; }
1786 | XMLCDATA { $$ = $1; }
1787 | XMLPI { $$ = $1; }
1791 /* 11.1 Primary Expressions {{{ */
1793 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1794 | XMLInitialiser { $$ = $1; }
1795 | XMLListInitialiser { $$ = $1; }
1799 : AttributeIdentifier { $$ = $1; }
1800 | QualifiedIdentifier { $$ = $1; }
1801 | WildcardIdentifier { $$ = $1; }
1804 /* 11.1.1 Attribute Identifiers {{{ */
1806 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1810 : PropertySelector { $$ = $1; }
1811 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1815 : Identifier { $$ = CYNew CYSelector($1); }
1816 | WildcardIdentifier { $$ = $1; }
1819 /* 11.1.2 Qualified Identifiers {{{ */
1820 QualifiedIdentifier_
1821 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1822 | QualifiedIdentifier { $$ = $1; }
1826 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1829 /* 11.1.3 Wildcard Identifiers {{{ */
1831 : "*" { $$ = CYNew CYWildcard(); }
1834 /* 11.1.4 XML Initialiser {{{ */
1836 : XMLMarkup { $$ = $1; }
1837 | XMLElement { $$ = $1; }
1841 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1842 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1846 : LexPushXMLTag XMLTagName XMLAttributes
1850 : BRACE LexPushRegExp Expression LexPop "}"
1859 : XMLAttributes_ XMLAttribute
1864 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1865 | XMLAttributes_ XMLWhitespaceOpt
1874 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1878 : XMLExpression XMLElementContentOpt
1879 | XMLMarkup XMLElementContentOpt
1880 | XMLText XMLElementContentOpt
1881 | XMLElement XMLElementContentOpt
1884 XMLElementContentOpt
1889 /* 11.1.5 XMLList Initialiser {{{ */
1891 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1895 /* 11.2 Left-Hand-Side Expressions {{{ */
1897 : Identifier { $$ = $1; }
1898 | PropertyIdentifier { $$ = $1; }
1902 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1903 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1904 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1907 /* 12.1 The default xml namespace Statement {{{ */
1908 /* XXX: DefaultXMLNamespaceStatement
1909 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1913 : DefaultXMLNamespaceStatement { $$ = $1; }
1918 /* JavaScript 1.7: Array Comprehensions {{{ */
1920 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
1924 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1925 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1928 /* JavaScript 1.7: for each {{{ */
1930 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1933 /* JavaScript 1.7: let Statements {{{ */
1935 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1943 /* JavaScript FTW: Ruby Blocks {{{ */
1944 RubyProcParameterList_
1945 : "," RubyProcParameterList { $$ = $2; }
1949 RubyProcParameterList
1950 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1955 : "|" RubyProcParameterList "|" { $$ = $2; }
1956 | "||" { $$ = NULL; }
1959 RubyProcParametersOpt
1960 : RubyProcParameters
1965 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1969 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1973 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }