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_;
79 CYProperty *property_;
80 CYPropertyName *propertyName_;
81 CYRubyProc *rubyProc_;
82 CYTypeSpecifier *specifier_;
83 CYStatement *statement_;
90 CYClassName *className_;
93 CYMessageParameter *messageParameter_;
94 CYProtocol *protocol_;
95 CYSelectorPart *selector_;
96 CYTypeModifier *modifier_;
97 CYTypedIdentifier *typedIdentifier_;
98 CYTypedParameter *typedParameter_;
102 CYAttribute *attribute_;
103 CYPropertyIdentifier *propertyIdentifier_;
104 CYSelector *selector_;
109 #define YYSTYPE YYSTYPE
112 @if Bison24 %code provides {
113 int cylex(YYSTYPE *, cy::location *, void *);
120 @if Bison23 %skeleton "lalr1.cc"
121 @if Bison24 %language "C++"
124 @$.begin.filename = @$.end.filename = &driver.filename_;
135 %parse-param { CYDriver &driver }
136 %lex-param { void *cyscanner }
138 /* Token Declarations {{{ */
144 %token XMLAttributeValue
146 %token XMLTagCharacters
152 %token LeftRight "<>"
153 %token LeftSlashRight "</>"
155 %token SlashRight "/>"
156 %token LeftSlash "</"
158 %token ColonColon "::"
159 %token PeriodPeriod ".."
162 @begin E4X ObjectiveC
168 %token AmpersandAmpersand "&&"
169 %token AmpersandEqual "&="
171 %token CarrotEqual "^="
173 %token EqualEqual "=="
174 %token EqualEqualEqual "==="
175 %token EqualRight "=>"
176 %token Exclamation "!"
177 %token ExclamationEqual "!="
178 %token ExclamationEqualEqual "!=="
180 %token HyphenEqual "-="
181 %token HyphenHyphen "--"
182 %token HyphenHyphen_ "\n--"
183 %token HyphenRight "->"
185 %token LeftEqual "<="
187 %token LeftLeftEqual "<<="
189 %token PercentEqual "%="
191 %token PeriodPeriodPeriod "..."
193 %token PipeEqual "|="
196 %token PlusEqual "+="
198 %token PlusPlus_ "\n++"
200 %token RightEqual ">="
201 %token RightRight ">>"
202 %token RightRightEqual ">>="
203 %token RightRightRight ">>>"
204 %token RightRightRightEqual ">>>="
206 %token SlashEqual "/="
208 %token StarEqual "*="
217 %token <comment_> Comment
220 %token CloseParen ")"
223 %token OpenBrace_ "\n{"
224 %token OpenBrace__ ";{"
225 %token CloseBrace "}"
227 %token OpenBracket "["
228 %token CloseBracket "]"
230 %token AtError "@error"
233 %token AtClass "@class"
237 %token <identifier_> Typedef "typedef"
238 %token <identifier_> Unsigned "unsigned"
239 %token <identifier_> Signed "signed"
243 %token AtImplementation "@implementation"
244 %token AtImplementation_ ";@implementation"
245 %token AtImport "@import"
246 %token AtEncode "@encode"
248 %token AtSelector "@selector"
249 %token <identifier_> Yes "YES"
250 %token <identifier_> No "NO"
253 %token <false_> False "false"
254 %token <null_> Null "null"
255 %token <true_> True "true"
257 // ES3/ES5/WIE/JSC Reserved
258 %token <word_> Auto "auto"
259 %token <word_> Break "break"
260 %token <word_> Case "case"
261 %token <word_> Catch "catch"
262 %token <word_> Continue "continue"
263 %token <word_> Default "default"
264 %token <word_> Delete "delete"
265 %token <word_> Do "do"
266 %token <word_> Else "else"
267 %token <word_> Finally "finally"
268 %token <word_> For "for"
269 %token <word_> Function "function"
270 %token <word_> Function_ ";function"
271 %token <word_> If "if"
272 %token <word_> In "in"
273 %token <word_> In_ "!in"
274 %token <word_> InstanceOf "instanceof"
275 %token <word_> New "new"
276 %token <word_> Return "return"
277 %token <word_> Switch "switch"
278 %token <this_> This "this"
279 %token <word_> Throw "throw"
280 %token <word_> Try "try"
281 %token <word_> TypeOf "typeof"
282 %token <word_> Var "var"
283 %token <word_> Void "void"
284 %token <word_> While "while"
285 %token <word_> With "with"
287 // ES3/IE6 Future, ES5/JSC Reserved
288 %token <word_> Debugger "debugger"
290 // ES3/ES5/IE6 Future, JSC Reserved
291 %token <word_> Const "const"
293 // ES3/ES5/IE6/JSC Future
294 %token <word_> Class "class"
295 %token <word_> Enum "enum"
296 %token <word_> Export "export"
297 %token <word_> Extends "extends"
298 %token <word_> Import "import"
299 %token <word_> Super "super"
301 // ES3 Future, ES5 Strict Future
302 %token <identifier_> Implements "implements"
303 %token <identifier_> Interface "interface"
304 %token <identifier_> Package "package"
305 %token <identifier_> Private "private"
306 %token <identifier_> Protected "protected"
307 %token <identifier_> Public "public"
308 %token <identifier_> Static "static"
311 %token <identifier_> Abstract "abstract"
312 %token <identifier_> Boolean "boolean"
313 %token <identifier_> Byte "byte"
314 %token <identifier_> Char "char"
315 %token <identifier_> Double "double"
316 %token <identifier_> Final "final"
317 %token <identifier_> Float "float"
318 %token <identifier_> Goto "goto"
319 %token <identifier_> Int "int"
320 %token <identifier_> Long "long"
321 %token <identifier_> Native "native"
322 %token <identifier_> Short "short"
323 %token <identifier_> Synchronized "synchronized"
324 %token <identifier_> Throws "throws"
325 %token <identifier_> Transient "transient"
326 %token <identifier_> Volatile "volatile"
329 %token <identifier_> Let "let"
330 %token <identifier_> Yield "yield"
333 %token <identifier_> Each "each"
334 %token <identifier_> Of "of"
338 %token <identifier_> Namespace "namespace"
339 %token <identifier_> XML "xml"
344 %token <identifier_> Identifier_
345 %token <number_> NumericLiteral
346 %token <string_> StringLiteral
347 %token <literal_> RegularExpressionLiteral
349 %type <expression_> AdditiveExpression
350 %type <argument_> ArgumentList_
351 %type <argument_> ArgumentList
352 %type <argument_> ArgumentListOpt
353 %type <argument_> Arguments
354 %type <expression_> ArrayComprehension
355 %type <expression_> ArrayInitialiser
356 %type <literal_> ArrayLiteral
357 %type <expression_> ArrowFunction
358 %type <functionParameter_> ArrowParameters
359 %type <expression_> AssignmentExpression
360 %type <identifier_> Binding
361 %type <identifier_> BindingIdentifier
362 %type <expression_> BitwiseANDExpression
363 %type <statement_> Block_
364 %type <statement_> Block
365 %type <boolean_> BooleanLiteral
366 %type <declaration_> BindingElement
367 %type <expression_> BitwiseORExpression
368 %type <expression_> BitwiseXORExpression
369 %type <statement_> BreakStatement
370 %type <statement_> BreakableStatement
371 %type <expression_> CallExpression_
372 %type <expression_> CallExpression
373 %type <clause_> CaseBlock
374 %type <clause_> CaseClause
375 %type <clause_> CaseClausesOpt
376 %type <catch_> CatchOpt
377 %type <expression_> Comprehension
378 %type <comprehension_> ComprehensionFor
379 %type <comprehension_> ComprehensionIf
380 %type <comprehension_> ComprehensionTail
381 %type <expression_> ConditionalExpression
382 %type <statement_> ContinueStatement
383 %type <statement_> ConciseBody
384 %type <statement_> DebuggerStatement
385 %type <statement_> Declaration__
386 %type <statement_> Declaration_
387 %type <statement_> Declaration
388 %type <clause_> DefaultClause
389 %type <expression_> Element
390 %type <expression_> ElementOpt
391 %type <element_> ElementList
392 %type <element_> ElementListOpt
393 %type <statement_> ElseStatementOpt
394 %type <statement_> EmptyStatement
395 %type <expression_> EqualityExpression
396 %type <compound_> Expression_
397 %type <compound_> Expression
398 %type <expression_> ExpressionOpt
399 %type <statement_> ExpressionStatement
400 %type <finally_> FinallyOpt
401 %type <for_> ForStatementInitialiser
402 %type <forin_> ForInStatementInitialiser
403 %type <declaration_> FormalParameter
404 %type <functionParameter_> FormalParameterList_
405 %type <functionParameter_> FormalParameterList
406 %type <functionParameter_> FormalParameterListOpt
407 %type <statement_> FunctionBody
408 %type <statement_> FunctionDeclaration
409 %type <expression_> FunctionExpression
410 %type <identifier_> Identifier
411 %type <identifier_> IdentifierOpt
412 %type <identifier_> IdentifierType
413 %type <word_> IdentifierName
414 %type <statement_> IfStatement
415 %type <expression_> Initialiser
416 %type <expression_> InitialiserOpt
417 %type <statement_> IterationStatement
418 %type <statement_> LabelledStatement
419 %type <expression_> LeftHandSideExpression
420 %type <statement_> LetStatement
421 %type <statement_> LexicalDeclaration
422 %type <literal_> Literal
423 %type <literal_> ValueLiteral
424 %type <expression_> LogicalANDExpression
425 %type <expression_> LogicalORExpression
426 %type <member_> MemberAccess
427 %type <expression_> MemberExpression_
428 %type <expression_> MemberExpression
429 %type <expression_> MultiplicativeExpression
430 %type <expression_> NewExpression
431 %type <null_> NullLiteral
432 %type <literal_> ObjectLiteral
433 %type <compound_> Parenthetical
434 %type <compound_> ParentheticalOpt
435 %type <expression_> PostfixExpression
436 %type <expression_> PrimaryExpression
437 %type <statement_> Program
438 %type <statement_> ProgramBody
439 %type <statement_> ProgramBodyOpt
440 %type <propertyName_> PropertyName_
441 %type <propertyName_> PropertyName
442 %type <property_> PropertyDefinition
443 %type <property_> PropertyDefinitionList_
444 %type <property_> PropertyDefinitionList
445 %type <property_> PropertyDefinitionListOpt
446 %type <expression_> RelationalExpression
447 %type <statement_> ReturnStatement
448 %type <rubyProc_> RubyProcExpression
449 %type <functionParameter_> RubyProcParameterList_
450 %type <functionParameter_> RubyProcParameterList
451 %type <functionParameter_> RubyProcParameters
452 %type <functionParameter_> RubyProcParametersOpt
453 %type <expression_> ShiftExpression
454 %type <declaration_> SingleNameBinding
455 %type <statement_> Statement__
456 %type <statement_> Statement_
457 %type <statement_> Statement
458 %type <statement_> StatementList
459 %type <statement_> StatementListOpt
460 %type <statement_> StatementListItem
461 %type <statement_> SwitchStatement
462 %type <statement_> ThrowStatement
463 %type <statement_> TryStatement
464 %type <expression_> UnaryExpression_
465 %type <expression_> UnaryExpression
466 %type <declaration_> VariableDeclaration
467 %type <declarations_> VariableDeclarationList_
468 %type <declarations_> VariableDeclarationList
469 %type <statement_> VariableStatement
470 %type <statement_> WithStatement
472 %type <word_> WordOpt
473 %type <expression_> Variable
476 %type <typedIdentifier_> ArrayedType
477 %type <expression_> BoxableExpression
478 %type <statement_> CategoryStatement
479 %type <expression_> ClassExpression
480 %type <field_> ClassFieldListOpt
481 %type <field_> ClassFields
482 %type <statement_> ClassStatement
483 %type <expression_> ClassSuperOpt
484 %type <message_> ClassMessageDeclaration
485 %type <message_> ClassMessageDeclarationListOpt
486 %type <className_> ClassName
487 %type <className_> ClassNameOpt
488 %type <protocol_> ClassProtocolListOpt
489 %type <protocol_> ClassProtocols
490 %type <protocol_> ClassProtocolsOpt
491 %type <expression_> EncodedType
492 %type <modifier_> FunctionedType
493 %type <specifier_> IntegerType
494 %type <specifier_> IntegerTypeOpt
495 %type <expression_> MessageExpression
496 %type <messageParameter_> MessageParameter
497 %type <messageParameter_> MessageParameters
498 %type <messageParameter_> MessageParameterList
499 %type <messageParameter_> MessageParameterListOpt
500 %type <bool_> MessageScope
501 %type <typedIdentifier_> ModifiedType
502 %type <module_> Module
503 %type <typedIdentifier_> PrefixedType
504 %type <specifier_> PrimitiveType
505 %type <argument_> SelectorCall_
506 %type <argument_> SelectorCall
507 %type <selector_> SelectorExpression_
508 %type <selector_> SelectorExpression
509 %type <selector_> SelectorExpressionOpt
510 %type <argument_> SelectorList
511 %type <word_> SelectorWordOpt
512 %type <typedIdentifier_> SuffixedType
513 %type <expression_> TypeOpt
514 %type <typedIdentifier_> TypeParenthetical
515 %type <modifier_> TypeQualifierLeft
516 %type <typedIdentifier_> TypeQualifierRight
517 %type <typedIdentifier_> TypeSignifier
518 %type <typedIdentifier_> TypedIdentifier
519 %type <typedParameter_> TypedParameterList_
520 %type <typedParameter_> TypedParameterList
521 %type <typedParameter_> TypedParameterListOpt
522 %type <argument_> VariadicCall
526 %type <propertyIdentifier_> PropertyIdentifier_
527 %type <selector_> PropertySelector_
528 %type <selector_> PropertySelector
529 %type <identifier_> QualifiedIdentifier_
530 %type <identifier_> QualifiedIdentifier
531 %type <identifier_> WildcardIdentifier
532 %type <identifier_> XMLComment
533 %type <identifier_> XMLCDATA
534 %type <identifier_> XMLElement
535 %type <identifier_> XMLElementContent
536 %type <identifier_> XMLMarkup
537 %type <identifier_> XMLPI
539 %type <attribute_> AttributeIdentifier
540 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
541 %type <expression_> PropertyIdentifier
542 %type <expression_> XMLListInitialiser
543 %type <expression_> XMLInitialiser
546 /* Token Priorities {{{ */
558 /* Lexer State {{{ */
560 : { driver.in_.push(true); }
564 : { driver.in_.push(false); }
568 : { driver.in_.pop(); }
572 : { driver.SetCondition(CYDriver::RegExpCondition); }
576 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
580 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
583 LexNoAtImplementation :
585 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
590 : LexNoBrace LexNoFunction LexNoAtImplementation
593 /* Virtual Tokens {{{ */
604 /* 7.6 Identifier Names and Identifiers {{{ */
615 : Identifier { $$ = $1; }
616 | "auto" { $$ = $1; }
617 | "break" NewLineOpt { $$ = $1; }
618 | "case" { $$ = $1; }
619 | "catch" { $$ = $1; }
620 | "class" { $$ = $1; }
621 | "const" { $$ = $1; }
622 | "continue" NewLineOpt { $$ = $1; }
623 | "debugger" { $$ = $1; }
624 | "default" { $$ = $1; }
625 | "delete" { $$ = $1; }
627 | "else" { $$ = $1; }
628 | "enum" { $$ = $1; }
629 | "export" { $$ = $1; }
630 | "extends" { $$ = $1; }
631 | "false" { $$ = $1; }
632 | "finally" { $$ = $1; }
633 /* XXX: | "for" { $$ = $1; } */
634 | "function" { $$ = $1; }
636 | "import" { $$ = $1; }
637 /* XXX: | "in" { $$ = $1; } */
639 /* XXX: | "instanceof" { $$ = $1; } */
641 // XXX: as it currently is not an Identifier
645 | "null" { $$ = $1; }
646 | "return" NewLineOpt { $$ = $1; }
647 | "super" { $$ = $1; }
648 | "switch" { $$ = $1; }
649 | "this" { $$ = $1; }
650 | "throw" NewLineOpt { $$ = $1; }
651 | "true" { $$ = $1; }
653 | "typeof" { $$ = $1; }
655 | "void" { $$ = $1; }
656 | "while" { $$ = $1; }
657 | "with" { $$ = $1; }
666 : Identifier_ { $$ = $1; }
668 | "implements" { $$ = $1; }
669 | "interface" { $$ = $1; }
670 | "package" { $$ = $1; }
671 | "private" { $$ = $1; }
672 | "protected" { $$ = $1; }
673 | "public" { $$ = $1; }
674 | "static" { $$ = $1; }
676 | "abstract" { $$ = $1; }
677 | "boolean" { $$ = $1; }
678 | "byte" { $$ = $1; }
679 | "double" { $$ = $1; }
680 | "final" { $$ = $1; }
681 | "float" { $$ = $1; }
682 | "goto" { $$ = $1; }
683 | "native" { $$ = $1; }
684 | "synchronized" { $$ = $1; }
685 | "throws" { $$ = $1; }
686 | "transient" { $$ = $1; }
688 // XXX: currently I only have this as Word
689 // | "let" { $$ = $1; }
691 | "yield" { $$ = $1; }
693 | "each" { $$ = $1; }
699 | "char" { $$ = $1; }
701 | "long" { $$ = $1; }
702 | "short" { $$ = $1; }
703 | "volatile" { $$ = $1; }
705 | "typedef" { $$ = $1; }
706 | "unsigned" { $$ = $1; }
707 | "signed" { $$ = $1; }
714 : Identifier { $$ = $1; }
719 /* 7.8 Literals {{{ */
721 : NullLiteral { $$ = $1; }
722 | ValueLiteral { $$ = $1; }
726 : BooleanLiteral { $$ = $1; }
727 | NumericLiteral { $$ = $1; }
728 | StringLiteral { $$ = $1; }
729 | RegularExpressionLiteral { $$ = $1; }
732 /* 7.8.1 Null Literals {{{ */
734 : "null" { $$ = $1; }
737 /* 7.8.2 Boolean Literals {{{ */
739 : "true" { $$ = $1; }
740 | "false" { $$ = $1; }
744 /* 7.9 Automatic Semicolon Insertion {{{ */
746 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
751 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
756 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
760 /* 11.1 Primary Expressions {{{ */
762 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
766 : Parenthetical { $$ = $1; }
771 : Identifier { $$ = CYNew CYVariable($1); }
775 : "this" { $$ = $1; }
776 | Variable { $$ = $1; }
777 | Literal { $$ = $1; }
778 | ArrayInitialiser { $$ = $1; }
779 | ObjectLiteral { $$ = $1; }
780 | Parenthetical { $$ = $1; }
781 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
784 /* 11.1.4 Array Initializer {{{ */
786 : ArrayLiteral { $$ = $1; }
787 | ArrayComprehension { $$ = $1; }
790 /* 11.1.4.1 Array Literal {{{ */
792 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
796 : AssignmentExpression { $$ = $1; }
800 : Element { $$ = $1; }
801 | LexSetRegExp { $$ = NULL; }
805 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
806 | Element { $$ = CYNew CYElement($1, NULL); }
810 : ElementList { $$ = $1; }
811 | LexSetRegExp { $$ = NULL; }
814 /* 11.1.4.2 Array Comprehension {{{ */
816 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
820 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
825 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
826 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
830 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
834 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
837 /* 11.1.5 Object Initialiser {{{ */
839 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
842 PropertyDefinitionList_
843 : "," PropertyDefinitionList { $$ = $2; }
844 | "," LexSetRegExp { $$ = NULL; }
848 PropertyDefinitionList
849 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
852 PropertyDefinitionListOpt
853 : PropertyDefinitionList { $$ = $1; }
854 | LexSetRegExp { $$ = NULL; }
858 // XXX: this should be IdentifierName
859 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
860 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
865 : IdentifierName { $$ = $1; }
866 | StringLiteral { $$ = $1; }
867 | NumericLiteral { $$ = $1; }
871 : LexSetRegExp PropertyName_ { $$ = $2; }
875 /* 11.2 Left-Hand-Side Expressions {{{ */
877 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
878 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
879 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
883 : MemberExpression { $$ = $1; }
884 //| "super" { $$ = $1; }
888 : LexSetRegExp PrimaryExpression { $$ = $2; }
889 | LexSetRegExp FunctionExpression { $$ = $2; }
890 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
891 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
895 : MemberExpression { $$ = $1; }
896 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
905 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
906 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
910 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
914 : "," ArgumentList { $$ = $2; }
919 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
923 : ArgumentList { $$ = $1; }
924 | LexSetRegExp { $$ = NULL; }
927 LeftHandSideExpression
928 : NewExpression { $$ = $1; }
929 | CallExpression { $$ = $1; }
932 /* 11.3 Postfix Expressions {{{ */
934 : %prec "" LeftHandSideExpression { $$ = $1; }
935 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
936 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
939 /* 11.4 Unary Operators {{{ */
941 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
942 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
943 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
944 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
945 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
946 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
947 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
948 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
949 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
950 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
951 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
955 : PostfixExpression { $$ = $1; }
956 | LexSetRegExp UnaryExpression_ { $$ = $2; }
959 /* 11.5 Multiplicative Operators {{{ */
960 MultiplicativeExpression
961 : UnaryExpression { $$ = $1; }
962 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
963 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
964 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
967 /* 11.6 Additive Operators {{{ */
969 : MultiplicativeExpression { $$ = $1; }
970 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
971 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
974 /* 11.7 Bitwise Shift Operators {{{ */
976 : AdditiveExpression { $$ = $1; }
977 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
978 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
979 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
982 /* 11.8 Relational Operators {{{ */
984 : ShiftExpression { $$ = $1; }
985 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
986 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
987 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
988 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
989 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
990 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
993 /* 11.9 Equality Operators {{{ */
995 : RelationalExpression { $$ = $1; }
996 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
997 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
998 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
999 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1002 /* 11.10 Binary Bitwise Operators {{{ */
1003 BitwiseANDExpression
1004 : EqualityExpression { $$ = $1; }
1005 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1008 BitwiseXORExpression
1009 : BitwiseANDExpression { $$ = $1; }
1010 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1014 : BitwiseXORExpression { $$ = $1; }
1015 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1018 /* 11.11 Binary Logical Operators {{{ */
1019 LogicalANDExpression
1020 : BitwiseORExpression { $$ = $1; }
1021 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1025 : LogicalANDExpression { $$ = $1; }
1026 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1029 /* 11.12 Conditional Operator ( ? : ) {{{ */
1030 ConditionalExpression
1031 : LogicalORExpression { $$ = $1; }
1032 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1033 | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1036 /* 11.13 Assignment Operators {{{ */
1037 AssignmentExpression
1038 : ConditionalExpression { $$ = $1; }
1039 | ArrowFunction { $$ = $1; }
1040 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1041 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1042 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1043 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1044 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1045 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1046 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1047 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1048 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1049 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1050 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1051 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1054 /* 11.14 Comma Operator {{{ */
1056 : "," Expression { $$ = $2; }
1057 | { $$ = CYNew CYCompound(); }
1061 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1065 : Expression { $$ = $1; }
1066 | LexSetRegExp { $$ = NULL; }
1070 /* 12 Statements {{{ */
1072 : Block { $$ = $1; }
1073 | VariableStatement { $$ = $1; }
1074 | EmptyStatement { $$ = $1; }
1075 | IfStatement { $$ = $1; }
1076 | BreakableStatement { $$ = $1; }
1077 | ContinueStatement { $$ = $1; }
1078 | BreakStatement { $$ = $1; }
1079 | ReturnStatement { $$ = $1; }
1080 | WithStatement { $$ = $1; }
1081 | LabelledStatement { $$ = $1; }
1082 | ThrowStatement { $$ = $1; }
1083 | TryStatement { $$ = $1; }
1084 | DebuggerStatement { $$ = $1; }
1088 : LexSetRegExp Statement__ { $$ = $2; }
1089 | ExpressionStatement { $$ = $1; }
1093 : LexSetStatement Statement_ { $$ = $2; }
1097 : FunctionDeclaration { $$ = $1; }
1098 | LexicalDeclaration { $$ = $1; }
1102 : LexSetRegExp Declaration__ { $$ = $2; }
1106 : LexSetStatement Declaration_ { $$ = $2; }
1110 : IterationStatement { $$ = $1; }
1111 | SwitchStatement { $$ = $1; }
1114 /* 12.1 Block {{{ */
1116 : BRACE StatementListOpt "}" { $$ = $2; }
1120 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1124 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1128 : StatementList { $$ = $1; }
1129 | LexSetStatement LexSetRegExp { $$ = NULL; }
1133 : Statement { $$ = $1; }
1134 | Declaration { $$ = $1; }
1138 /* 12.2 Declarations {{{ */
1140 : Identifier { $$ = $1; }
1147 // XXX: BindingPattern
1149 /* 12.2.1 Let and Const Declarations {{{ */
1151 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1159 /* 12.2.2 Variable Statement {{{ */
1161 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1164 VariableDeclarationList_
1165 : "," VariableDeclarationList { $$ = $2; }
1169 VariableDeclarationList
1170 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1174 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1175 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1179 : "=" AssignmentExpression { $$ = $2; }
1183 : Initialiser { $$ = $1; }
1187 /* 12.2.4 Destructuring Binding Patterns {{{ */
1191 : SingleNameBinding { $$ = $1; }
1195 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1199 /* 12.3 Empty Statement {{{ */
1201 : ";" { $$ = CYNew CYEmpty(); }
1204 /* 12.4 Expression Statement {{{ */
1206 : Expression Terminator { $$ = CYNew CYExpress($1); }
1209 /* 12.5 The if Statement {{{ */
1211 : "else" Statement { $$ = $2; }
1212 | %prec "if" { $$ = NULL; }
1216 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1220 /* 12.6.1 The do-while Statement {{{ */
1222 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1225 /* 12.6.2 The while Statement {{{ */
1227 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1230 /* 12.6.3 The for Statement {{{ */
1232 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1235 ForStatementInitialiser
1236 : ExpressionOpt { $$ = $1; }
1237 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1240 /* 12.6.4 The for-in and for-of Statements {{{ */
1242 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1243 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1246 ForInStatementInitialiser
1247 : LeftHandSideExpression { $$ = $1; }
1248 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1252 /* 12.7 The continue Statement {{{ */
1254 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1255 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1258 /* 12.8 The break Statement {{{ */
1260 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1261 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1264 /* 12.9 The return Statement {{{ */
1266 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1267 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1270 /* 12.10 The with Statement {{{ */
1272 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1276 /* 12.11 The switch Statement {{{ */
1278 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1282 : BRACE CaseClausesOpt "}" { $$ = $2; }
1286 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1290 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1291 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1296 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1299 /* 12.12 Labelled Statements {{{ */
1301 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1304 /* 12.13 The throw Statement {{{ */
1306 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1307 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1310 /* 12.14 The try Statement {{{ */
1312 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1316 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1321 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1325 /* 12.14 The debugger Statement {{{ */
1327 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1331 /* 13.1 Function Definitions {{{ */
1333 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1337 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1340 FormalParameterList_
1341 : "," FormalParameterList { $$ = $2; }
1346 // XXX: : FunctionRestParameter { $$ = $1; }
1347 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1350 FormalParameterListOpt
1351 : FormalParameterList
1355 /* XXX: FunctionRestParameter
1356 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1360 : BindingElement { $$ = $1; }
1364 : StatementListOpt { $$ = $1; }
1367 /* 13.2 Arrow Function Definitions {{{ */
1369 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1373 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1374 //| ParentheticalOpt { $$ = $1; }
1378 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1379 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1382 /* 14 Program {{{ */
1384 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1388 : StatementList { $$ = $1; }
1392 : ProgramBody { $$ = $1; }
1393 | LexSetStatement LexSetRegExp { $$ = NULL; }
1398 /* Cycript (Objective-C): Type Encoding {{{ */
1400 : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1404 : IdentifierType { $$ = CYNew CYTypedIdentifier($1); }
1405 | TypeParenthetical { $$ = $1; }
1409 : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1410 | TypeSignifier { $$ = $1; }
1411 | { $$ = CYNew CYTypedIdentifier(); }
1415 : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); }
1419 : ArrayedType { $$ = $1; }
1420 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1421 | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1422 | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1426 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1431 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1432 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1436 : PrefixedType { $$ = $1; }
1437 | SuffixedType { $$ = $1; }
1438 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1439 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1443 : "int" { $$ = CYNew CYTypeVariable("int"); }
1444 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1445 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1446 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1447 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1451 : IntegerType { $$ = $1; }
1452 | { $$ = CYNew CYTypeVariable("int"); }
1456 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1457 | IntegerType { $$ = $1; }
1458 | "void" { $$ = CYNew CYTypeVoid(); }
1459 | "char" { $$ = CYNew CYTypeVariable("char"); }
1460 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1461 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1465 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1469 : TypedIdentifier { $$ = CYNew CYEncodedType($1); }
1473 : "@encode" "(" EncodedType ")" { $$ = $3; }
1476 /* Cycript (Objective-C): @class Declaration {{{ */
1478 /* XXX: why the hell did I choose MemberExpression? */
1479 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1484 : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $3); }
1485 | LexSetRegExp { $$ = NULL; }
1489 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1493 : "+" { $$ = false; }
1494 | "-" { $$ = true; }
1498 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1503 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1506 MessageParameterList
1507 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1510 MessageParameterListOpt
1511 : MessageParameterList { $$ = $1; }
1516 : MessageParameterList { $$ = $1; }
1517 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1520 ClassMessageDeclaration
1521 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1524 ClassMessageDeclarationListOpt
1525 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1526 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1531 : Identifier { $$ = $1; }
1532 | "(" AssignmentExpression ")" { $$ = $2; }
1536 : ClassName { $$ = $1; }
1540 // XXX: this should be AssignmentExpressionNoRight
1542 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1546 : "," ClassProtocols { $$ = $2; }
1550 ClassProtocolListOpt
1551 : "<" ClassProtocols ">" { $$ = $2; }
1556 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1560 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1568 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1572 : ClassExpression { $$ = $1; }
1576 : ClassStatement { $$ = $1; }
1577 | CategoryStatement { $$ = $1; }
1580 /* Cycript (Objective-C): Send Message {{{ */
1582 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1587 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1588 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1592 : SelectorCall { $$ = $1; }
1593 | VariadicCall { $$ = $1; }
1597 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1601 : SelectorCall { $$ = $1; }
1602 | Word { $$ = CYNew CYArgument($1, NULL); }
1606 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1607 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1611 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1615 : SelectorExpression_ { $$ = $1; }
1616 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1619 SelectorExpressionOpt
1620 : SelectorExpression_ { $$ = $1; }
1625 : MessageExpression { $$ = $1; }
1626 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1629 /* Cycript (Objective-C): @import Directive {{{ */
1631 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1632 | Word { $$ = CYNew CYModule($1); }
1636 : "@import" Module { $$ = CYNew CYImport($2); }
1639 /* Cycript (Objective-C): Boxed Expressions {{{ */
1641 : NullLiteral { $$ = $1; }
1642 | BooleanLiteral { $$ = $1; }
1643 | NumericLiteral { $$ = $1; }
1644 | StringLiteral { $$ = $1; }
1645 | ArrayLiteral { $$ = $1; }
1646 | ObjectLiteral { $$ = $1; }
1647 | Parenthetical { $$ = $1; }
1648 | "YES" { $$ = CYNew CYTrue(); }
1649 | "NO" { $$ = CYNew CYFalse(); }
1653 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1656 /* Cycript (Objective-C): Block Expressions {{{ */
1658 : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->specifier_ = $2; $$->modifier_ = $1; }
1659 | ModifiedType "*" { $$ = $1; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1663 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1666 /* Cycript (Objective-C): Instance Literals {{{ */
1668 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
1674 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1675 LeftHandSideExpression
1676 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1680 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1684 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1685 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1686 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1689 /* Cycript (C): auto Compatibility {{{ */
1694 /* Cycript (C): Lambda Expressions {{{ */
1696 : "," TypedParameterList { $$ = $2; }
1701 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1704 TypedParameterListOpt
1705 : TypedParameterList { $$ = $1; }
1710 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1713 /* Cycript (C): Type Definitions {{{ */
1715 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1720 /* YUI: Documentation Comments {{{ */
1722 : Comment { $$ = $1; }
1727 /* Lexer State {{{ */
1729 : { driver.PushCondition(CYDriver::RegExpCondition); }
1733 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1737 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1741 : { driver.PopCondition(); }
1745 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1749 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1752 /* Virtual Tokens {{{ */
1759 /* 8.1 Context Keywords {{{ */
1761 : "namespace" { $$ = $1; }
1762 | "xml" { $$ = $1; }
1765 /* 8.3 XML Initialiser Input Elements {{{ */
1767 : XMLComment { $$ = $1; }
1768 | XMLCDATA { $$ = $1; }
1769 | XMLPI { $$ = $1; }
1773 /* 11.1 Primary Expressions {{{ */
1775 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1776 | XMLInitialiser { $$ = $1; }
1777 | XMLListInitialiser { $$ = $1; }
1781 : AttributeIdentifier { $$ = $1; }
1782 | QualifiedIdentifier { $$ = $1; }
1783 | WildcardIdentifier { $$ = $1; }
1786 /* 11.1.1 Attribute Identifiers {{{ */
1788 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1792 : PropertySelector { $$ = $1; }
1793 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1797 : Identifier { $$ = CYNew CYSelector($1); }
1798 | WildcardIdentifier { $$ = $1; }
1801 /* 11.1.2 Qualified Identifiers {{{ */
1802 QualifiedIdentifier_
1803 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1804 | QualifiedIdentifier { $$ = $1; }
1808 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1811 /* 11.1.3 Wildcard Identifiers {{{ */
1813 : "*" { $$ = CYNew CYWildcard(); }
1816 /* 11.1.4 XML Initialiser {{{ */
1818 : XMLMarkup { $$ = $1; }
1819 | XMLElement { $$ = $1; }
1823 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1824 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1828 : LexPushXMLTag XMLTagName XMLAttributes
1832 : BRACE LexPushRegExp Expression LexPop "}"
1841 : XMLAttributes_ XMLAttribute
1846 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1847 | XMLAttributes_ XMLWhitespaceOpt
1856 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1860 : XMLExpression XMLElementContentOpt
1861 | XMLMarkup XMLElementContentOpt
1862 | XMLText XMLElementContentOpt
1863 | XMLElement XMLElementContentOpt
1866 XMLElementContentOpt
1871 /* 11.1.5 XMLList Initialiser {{{ */
1873 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1877 /* 11.2 Left-Hand-Side Expressions {{{ */
1879 : Identifier { $$ = $1; }
1880 | PropertyIdentifier { $$ = $1; }
1884 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1885 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1886 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1889 /* 12.1 The default xml namespace Statement {{{ */
1890 /* XXX: DefaultXMLNamespaceStatement
1891 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1895 : DefaultXMLNamespaceStatement { $$ = $1; }
1900 /* JavaScript 1.7: Array Comprehensions {{{ */
1902 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
1906 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1907 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1910 /* JavaScript 1.7: for each {{{ */
1912 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1915 /* JavaScript 1.7: let Statements {{{ */
1917 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1925 /* JavaScript FTW: Ruby Blocks {{{ */
1926 RubyProcParameterList_
1927 : "," RubyProcParameterList { $$ = $2; }
1931 RubyProcParameterList
1932 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1937 : "|" RubyProcParameterList "|" { $$ = $2; }
1938 | "||" { $$ = NULL; }
1941 RubyProcParametersOpt
1942 : RubyProcParameters
1947 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1951 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1955 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }