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/>.
23 #define cyscanner driver.scanner_
24 #define YYSTACKEXPANDABLE 1
30 #define CYNew new($pool)
33 #include "ObjectiveC/Syntax.hpp"
37 #include "E4X/Syntax.hpp"
40 #include "Highlight.hpp"
49 CYDriver::Condition condition_;
51 CYArgument *argument_;
52 CYAssignment *assignment_;
55 cy::Syntax::Catch *catch_;
57 CYComprehension *comprehension_;
58 CYCompound *compound_;
59 CYDeclaration *declaration_;
60 CYDeclarations *declarations_;
62 CYExpression *expression_;
65 CYForInitialiser *for_;
66 CYForInInitialiser *forin_;
67 CYFunctionParameter *functionParameter_;
68 CYIdentifier *identifier_;
76 CYProperty *property_;
77 CYPropertyName *propertyName_;
78 CYRubyProc *rubyProc_;
79 CYStatement *statement_;
86 CYTypeModifier *modifier_;
87 CYTypeSpecifier *specifier_;
88 CYTypedIdentifier *typedIdentifier_;
89 CYTypedParameter *typedParameter_;
93 CYClassName *className_;
96 CYMessageParameter *messageParameter_;
97 CYProtocol *protocol_;
98 CYSelectorPart *selector_;
102 CYAttribute *attribute_;
103 CYPropertyIdentifier *propertyIdentifier_;
104 CYSelector *selector_;
109 #define YYSTYPE YYSTYPE
113 int cylex(YYSTYPE *, cy::location *, void *);
121 @$.begin.filename = @$.end.filename = &driver.filename_;
132 %parse-param { CYDriver &driver }
133 %lex-param { void *cyscanner }
135 /* Token Declarations {{{ */
141 %token XMLAttributeValue
143 %token XMLTagCharacters
149 %token LeftRight "<>"
150 %token LeftSlashRight "</>"
152 %token SlashRight "/>"
153 %token LeftSlash "</"
155 %token ColonColon "::"
156 %token PeriodPeriod ".."
159 @begin E4X ObjectiveC
165 %token AmpersandAmpersand "&&"
166 %token AmpersandEqual "&="
168 %token CarrotEqual "^="
170 %token EqualEqual "=="
171 %token EqualEqualEqual "==="
172 %token EqualRight "=>"
173 %token Exclamation "!"
174 %token ExclamationEqual "!="
175 %token ExclamationEqualEqual "!=="
177 %token HyphenEqual "-="
178 %token HyphenHyphen "--"
179 %token HyphenHyphen_ "\n--"
180 %token HyphenRight "->"
182 %token LeftEqual "<="
184 %token LeftLeftEqual "<<="
186 %token PercentEqual "%="
188 %token PeriodPeriodPeriod "..."
190 %token PipeEqual "|="
193 %token PlusEqual "+="
195 %token PlusPlus_ "\n++"
197 %token RightEqual ">="
198 %token RightRight ">>"
199 %token RightRightEqual ">>="
200 %token RightRightRight ">>>"
201 %token RightRightRightEqual ">>>="
203 %token SlashEqual "/="
205 %token StarEqual "*="
214 %token <comment_> Comment
217 %token CloseParen ")"
220 %token OpenBrace_ "\n{"
221 %token OpenBrace__ ";{"
222 %token CloseBrace "}"
224 %token OpenBracket "["
225 %token CloseBracket "]"
227 %token AtError "@error"
230 %token AtClass "@class"
234 %token <identifier_> Typedef "typedef"
235 %token <identifier_> Unsigned "unsigned"
236 %token <identifier_> Signed "signed"
237 %token <identifier_> Extern "extern"
241 %token AtEncode "@encode"
245 %token AtImplementation "@implementation"
246 %token AtImplementation_ ";@implementation"
247 %token AtImport "@import"
249 %token AtSelector "@selector"
250 %token <identifier_> Yes "YES"
251 %token <identifier_> No "NO"
254 %token <false_> False "false"
255 %token <null_> Null "null"
256 %token <true_> True "true"
258 // ES3/ES5/WIE/JSC Reserved
259 %token <word_> Auto "auto"
260 %token <word_> Break "break"
261 %token <word_> Case "case"
262 %token <word_> Catch "catch"
263 %token <word_> Continue "continue"
264 %token <word_> Default "default"
265 %token <word_> Delete "delete"
266 %token <word_> Do "do"
267 %token <word_> Else "else"
268 %token <word_> Finally "finally"
269 %token <word_> For "for"
270 %token <word_> Function "function"
271 %token <word_> Function_ ";function"
272 %token <word_> If "if"
273 %token <word_> In "in"
274 %token <word_> In_ "!in"
275 %token <word_> InstanceOf "instanceof"
276 %token <word_> New "new"
277 %token <word_> Return "return"
278 %token <word_> Switch "switch"
279 %token <this_> This "this"
280 %token <word_> Throw "throw"
281 %token <word_> Try "try"
282 %token <word_> TypeOf "typeof"
283 %token <word_> Var "var"
284 %token <word_> Void "void"
285 %token <word_> While "while"
286 %token <word_> With "with"
288 // ES3/IE6 Future, ES5/JSC Reserved
289 %token <word_> Debugger "debugger"
291 // ES3/ES5/IE6 Future, JSC Reserved
292 %token <word_> Const "const"
294 // ES3/ES5/IE6/JSC Future
295 %token <word_> Class "class"
296 %token <word_> Enum "enum"
297 %token <word_> Export "export"
298 %token <word_> Extends "extends"
299 %token <word_> Import "import"
300 %token <word_> Super "super"
302 // ES3 Future, ES5 Strict Future
303 %token <identifier_> Implements "implements"
304 %token <identifier_> Interface "interface"
305 %token <identifier_> Package "package"
306 %token <identifier_> Private "private"
307 %token <identifier_> Protected "protected"
308 %token <identifier_> Public "public"
309 %token <identifier_> Static "static"
312 %token <identifier_> Abstract "abstract"
313 %token <identifier_> Boolean "boolean"
314 %token <identifier_> Byte "byte"
315 %token <identifier_> Char "char"
316 %token <identifier_> Double "double"
317 %token <identifier_> Final "final"
318 %token <identifier_> Float "float"
319 %token <identifier_> Goto "goto"
320 %token <identifier_> Int "int"
321 %token <identifier_> Long "long"
322 %token <identifier_> Native "native"
323 %token <identifier_> Short "short"
324 %token <identifier_> Synchronized "synchronized"
325 %token <identifier_> Throws "throws"
326 %token <identifier_> Transient "transient"
327 %token <identifier_> Volatile "volatile"
330 %token <identifier_> Let "let"
331 %token <identifier_> Yield "yield"
334 %token <identifier_> Each "each"
335 %token <identifier_> Of "of"
339 %token <identifier_> Namespace "namespace"
340 %token <identifier_> XML "xml"
345 %token <identifier_> Identifier_
346 %token <number_> NumericLiteral
347 %token <string_> StringLiteral
348 %token <literal_> RegularExpressionLiteral
350 %type <expression_> AdditiveExpression
351 %type <argument_> ArgumentList_
352 %type <argument_> ArgumentList
353 %type <argument_> ArgumentListOpt
354 %type <argument_> Arguments
355 %type <expression_> ArrayComprehension
356 %type <expression_> ArrayInitialiser
357 %type <literal_> ArrayLiteral
358 %type <expression_> ArrowFunction
359 %type <functionParameter_> ArrowParameters
360 %type <expression_> AssignmentExpression
361 %type <identifier_> Binding
362 %type <identifier_> BindingIdentifier
363 %type <expression_> BitwiseANDExpression
364 %type <statement_> Block_
365 %type <statement_> Block
366 %type <boolean_> BooleanLiteral
367 %type <declaration_> BindingElement
368 %type <expression_> BitwiseORExpression
369 %type <expression_> BitwiseXORExpression
370 %type <statement_> BreakStatement
371 %type <statement_> BreakableStatement
372 %type <expression_> CallExpression_
373 %type <expression_> CallExpression
374 %type <clause_> CaseBlock
375 %type <clause_> CaseClause
376 %type <clause_> CaseClausesOpt
377 %type <catch_> CatchOpt
378 %type <expression_> Comprehension
379 %type <comprehension_> ComprehensionFor
380 %type <comprehension_> ComprehensionIf
381 %type <comprehension_> ComprehensionTail
382 %type <expression_> ConditionalExpression
383 %type <statement_> ContinueStatement
384 %type <statement_> ConciseBody
385 %type <statement_> DebuggerStatement
386 %type <statement_> Declaration__
387 %type <statement_> Declaration_
388 %type <statement_> Declaration
389 %type <clause_> DefaultClause
390 %type <expression_> Element
391 %type <expression_> ElementOpt
392 %type <element_> ElementList
393 %type <element_> ElementListOpt
394 %type <statement_> ElseStatementOpt
395 %type <statement_> EmptyStatement
396 %type <expression_> EqualityExpression
397 %type <compound_> Expression_
398 %type <compound_> Expression
399 %type <expression_> ExpressionOpt
400 %type <statement_> ExpressionStatement
401 %type <finally_> FinallyOpt
402 %type <for_> ForStatementInitialiser
403 %type <forin_> ForInStatementInitialiser
404 %type <declaration_> FormalParameter
405 %type <functionParameter_> FormalParameterList_
406 %type <functionParameter_> FormalParameterList
407 %type <functionParameter_> FormalParameterListOpt
408 %type <statement_> FunctionBody
409 %type <statement_> FunctionDeclaration
410 %type <expression_> FunctionExpression
411 %type <identifier_> Identifier
412 %type <identifier_> IdentifierOpt
413 %type <identifier_> IdentifierType
414 %type <word_> IdentifierName
415 %type <statement_> IfStatement
416 %type <expression_> Initialiser
417 %type <expression_> InitialiserOpt
418 %type <statement_> IterationStatement
419 %type <statement_> LabelledStatement
420 %type <expression_> LeftHandSideExpression
421 %type <statement_> LetStatement
422 %type <statement_> LexicalDeclaration
423 %type <literal_> Literal
424 %type <literal_> ValueLiteral
425 %type <expression_> LogicalANDExpression
426 %type <expression_> LogicalORExpression
427 %type <member_> MemberAccess
428 %type <expression_> MemberExpression_
429 %type <expression_> MemberExpression
430 %type <module_> Module
431 %type <expression_> MultiplicativeExpression
432 %type <expression_> NewExpression
433 %type <null_> NullLiteral
434 %type <literal_> ObjectLiteral
435 %type <compound_> Parenthetical
436 //%type <compound_> ParentheticalOpt
437 %type <expression_> PostfixExpression
438 %type <expression_> PrimaryExpression
439 %type <statement_> Program
440 %type <statement_> ProgramBody
441 %type <statement_> ProgramBodyOpt
442 %type <propertyName_> PropertyName_
443 %type <propertyName_> PropertyName
444 %type <property_> PropertyDefinition
445 %type <property_> PropertyDefinitionList_
446 %type <property_> PropertyDefinitionList
447 %type <property_> PropertyDefinitionListOpt
448 %type <expression_> RelationalExpression
449 %type <statement_> ReturnStatement
450 %type <rubyProc_> RubyProcExpression
451 %type <functionParameter_> RubyProcParameterList_
452 %type <functionParameter_> RubyProcParameterList
453 %type <functionParameter_> RubyProcParameters
454 %type <functionParameter_> RubyProcParametersOpt
455 %type <expression_> ShiftExpression
456 %type <declaration_> SingleNameBinding
457 %type <statement_> Statement__
458 %type <statement_> Statement_
459 %type <statement_> Statement
460 %type <statement_> StatementList
461 %type <statement_> StatementListOpt
462 %type <statement_> StatementListItem
463 %type <statement_> SwitchStatement
464 %type <statement_> ThrowStatement
465 %type <statement_> TryStatement
466 %type <expression_> UnaryExpression_
467 %type <expression_> UnaryExpression
468 %type <declaration_> VariableDeclaration
469 %type <declarations_> VariableDeclarationList_
470 %type <declarations_> VariableDeclarationList
471 %type <statement_> VariableStatement
472 %type <statement_> WithStatement
474 %type <word_> WordOpt
475 %type <expression_> Variable
478 %type <typedIdentifier_> ArrayedType
479 %type <modifier_> FunctionedType
480 %type <specifier_> IntegerType
481 %type <specifier_> IntegerTypeOpt
482 %type <typedIdentifier_> PrefixedType
483 %type <specifier_> PrimitiveType
484 %type <typedIdentifier_> TypeParenthetical
485 %type <typedIdentifier_> TypeSignifier
486 %type <typedIdentifier_> SuffixedType
487 %type <modifier_> TypeQualifierLeft
488 %type <typedIdentifier_> TypeQualifierRight
489 %type <typedIdentifier_> TypedIdentifier
490 %type <typedParameter_> TypedParameterList_
491 %type <typedParameter_> TypedParameterList
492 %type <typedParameter_> TypedParameterListOpt
496 %type <expression_> BoxableExpression
497 %type <statement_> CategoryStatement
498 %type <expression_> ClassExpression
499 %type <field_> ClassFieldListOpt
500 %type <field_> ClassFields
501 %type <statement_> ClassStatement
502 %type <expression_> ClassSuperOpt
503 %type <message_> ClassMessageDeclaration
504 %type <message_> ClassMessageDeclarationListOpt
505 %type <className_> ClassName
506 %type <className_> ClassNameOpt
507 %type <protocol_> ClassProtocolListOpt
508 %type <protocol_> ClassProtocols
509 %type <protocol_> ClassProtocolsOpt
510 %type <expression_> MessageExpression
511 %type <messageParameter_> MessageParameter
512 %type <messageParameter_> MessageParameters
513 %type <messageParameter_> MessageParameterList
514 %type <messageParameter_> MessageParameterListOpt
515 %type <bool_> MessageScope
516 %type <typedIdentifier_> ModifiedType
517 %type <argument_> SelectorCall_
518 %type <argument_> SelectorCall
519 %type <selector_> SelectorExpression_
520 %type <selector_> SelectorExpression
521 %type <selector_> SelectorExpressionOpt
522 %type <argument_> SelectorList
523 %type <word_> SelectorWordOpt
524 %type <typedIdentifier_> TypeOpt
525 %type <argument_> VariadicCall
529 %type <propertyIdentifier_> PropertyIdentifier_
530 %type <selector_> PropertySelector_
531 %type <selector_> PropertySelector
532 %type <identifier_> QualifiedIdentifier_
533 %type <identifier_> QualifiedIdentifier
534 %type <identifier_> WildcardIdentifier
535 %type <identifier_> XMLComment
536 %type <identifier_> XMLCDATA
537 %type <identifier_> XMLElement
538 %type <identifier_> XMLElementContent
539 %type <identifier_> XMLMarkup
540 %type <identifier_> XMLPI
542 %type <attribute_> AttributeIdentifier
543 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
544 %type <expression_> PropertyIdentifier
545 %type <expression_> XMLListInitialiser
546 %type <expression_> XMLInitialiser
549 /* Token Priorities {{{ */
561 /* Lexer State {{{ */
563 : { driver.in_.push(true); }
567 : { driver.in_.push(false); }
571 : { driver.in_.pop(); }
575 : { driver.SetCondition(CYDriver::RegExpCondition); }
579 : { if (yyla.empty()) driver.no_.OpenBrace = true; else if (yyla.type == yytranslate_(token::OpenBrace) || yyla.type == yytranslate_(token::OpenBrace_)) yyla.type = yytranslate_(token::OpenBrace__); }
583 : { if (yyla.empty()) driver.no_.Function = true; else if (yyla.type == yytranslate_(token::Function)) yyla.type = yytranslate_(token::Function_); }
586 LexNoAtImplementation :
588 { if (yyla.empty()) driver.no_.AtImplementation = true; else if (yyla.type == yytranslate_(token::AtImplementation)) yyla.type = yytranslate_(token::AtImplementation_); }
593 : LexNoBrace LexNoFunction LexNoAtImplementation
596 /* Virtual Tokens {{{ */
607 /* 7.6 Identifier Names and Identifiers {{{ */
618 : Identifier { $$ = $1; }
619 | "auto" { $$ = $1; }
620 | "break" NewLineOpt { $$ = $1; }
621 | "case" { $$ = $1; }
622 | "catch" { $$ = $1; }
623 | "class" { $$ = $1; }
624 | "const" { $$ = $1; }
625 | "continue" NewLineOpt { $$ = $1; }
626 | "debugger" { $$ = $1; }
627 | "default" { $$ = $1; }
628 | "delete" { $$ = $1; }
630 | "else" { $$ = $1; }
631 | "enum" { $$ = $1; }
632 | "export" { $$ = $1; }
633 | "extends" { $$ = $1; }
634 | "false" { $$ = $1; }
635 | "finally" { $$ = $1; }
636 /* XXX: | "for" { $$ = $1; } */
637 | "function" { $$ = $1; }
639 | "import" { $$ = $1; }
640 /* XXX: | "in" { $$ = $1; } */
642 /* XXX: | "instanceof" { $$ = $1; } */
644 // XXX: as it currently is not an Identifier
648 | "null" { $$ = $1; }
649 | "return" NewLineOpt { $$ = $1; }
650 | "super" { $$ = $1; }
651 | "switch" { $$ = $1; }
652 | "this" { $$ = $1; }
653 | "throw" NewLineOpt { $$ = $1; }
654 | "true" { $$ = $1; }
656 | "typeof" { $$ = $1; }
658 | "void" { $$ = $1; }
659 | "while" { $$ = $1; }
660 | "with" { $$ = $1; }
669 : Identifier_ { $$ = $1; }
671 | "implements" { $$ = $1; }
672 | "interface" { $$ = $1; }
673 | "package" { $$ = $1; }
674 | "private" { $$ = $1; }
675 | "protected" { $$ = $1; }
676 | "public" { $$ = $1; }
677 | "static" { $$ = $1; }
679 | "abstract" { $$ = $1; }
680 | "boolean" { $$ = $1; }
681 | "byte" { $$ = $1; }
682 | "double" { $$ = $1; }
683 | "final" { $$ = $1; }
684 | "float" { $$ = $1; }
685 | "goto" { $$ = $1; }
686 | "native" { $$ = $1; }
687 | "synchronized" { $$ = $1; }
688 | "throws" { $$ = $1; }
689 | "transient" { $$ = $1; }
691 // XXX: currently I only have this as Word
692 // | "let" { $$ = $1; }
694 | "yield" { $$ = $1; }
696 | "each" { $$ = $1; }
702 | "char" { $$ = $1; }
704 | "long" { $$ = $1; }
705 | "short" { $$ = $1; }
706 | "volatile" { $$ = $1; }
708 | "typedef" { $$ = $1; }
709 | "unsigned" { $$ = $1; }
710 | "signed" { $$ = $1; }
711 | "extern" { $$ = $1; }
720 : Identifier { $$ = $1; }
725 /* 7.8 Literals {{{ */
727 : NullLiteral { $$ = $1; }
728 | ValueLiteral { $$ = $1; }
732 : BooleanLiteral { $$ = $1; }
733 | NumericLiteral { $$ = $1; }
734 | StringLiteral { $$ = $1; }
735 | RegularExpressionLiteral { $$ = $1; }
738 /* 7.8.1 Null Literals {{{ */
740 : "null" { $$ = $1; }
743 /* 7.8.2 Boolean Literals {{{ */
745 : "true" { $$ = $1; }
746 | "false" { $$ = $1; }
750 /* 7.9 Automatic Semicolon Insertion {{{ */
752 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
757 | error { if (yyla.type_get() != yyeof_ && yyla.type != token::CloseBrace && !yyla.value.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
762 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
766 /* 11.1 Primary Expressions {{{ */
768 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
772 : Parenthetical { $$ = $1; }
777 : Identifier { $$ = CYNew CYVariable($1); }
781 : "this" { $$ = $1; }
782 | Variable { $$ = $1; }
783 | Literal { $$ = $1; }
784 | ArrayInitialiser { $$ = $1; }
785 | ObjectLiteral { $$ = $1; }
786 | Parenthetical { $$ = $1; }
787 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
790 /* 11.1.4 Array Initializer {{{ */
792 : ArrayLiteral { $$ = $1; }
793 | ArrayComprehension { $$ = $1; }
796 /* 11.1.4.1 Array Literal {{{ */
798 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
802 : AssignmentExpression { $$ = $1; }
806 : Element { $$ = $1; }
807 | LexSetRegExp { $$ = NULL; }
811 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
812 | Element { $$ = CYNew CYElement($1, NULL); }
816 : ElementList { $$ = $1; }
817 | LexSetRegExp { $$ = NULL; }
820 /* 11.1.4.2 Array Comprehension {{{ */
822 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
826 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
831 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
832 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
836 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
840 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
843 /* 11.1.5 Object Initialiser {{{ */
845 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
848 PropertyDefinitionList_
849 : "," PropertyDefinitionList { $$ = $2; }
850 | "," LexSetRegExp { $$ = NULL; }
854 PropertyDefinitionList
855 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
858 PropertyDefinitionListOpt
859 : PropertyDefinitionList { $$ = $1; }
860 | LexSetRegExp { $$ = NULL; }
864 // XXX: this should be IdentifierName
865 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
866 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
871 : IdentifierName { $$ = $1; }
872 | StringLiteral { $$ = $1; }
873 | NumericLiteral { $$ = $1; }
877 : LexSetRegExp PropertyName_ { $$ = $2; }
881 /* 11.2 Left-Hand-Side Expressions {{{ */
883 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
884 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
885 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
889 : MemberExpression { $$ = $1; }
890 //| "super" { $$ = $1; }
894 : LexSetRegExp PrimaryExpression { $$ = $2; }
895 | LexSetRegExp FunctionExpression { $$ = $2; }
896 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
897 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
901 : MemberExpression { $$ = $1; }
902 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
911 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
912 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
916 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
920 : "," ArgumentList { $$ = $2; }
925 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
929 : ArgumentList { $$ = $1; }
930 | LexSetRegExp { $$ = NULL; }
933 LeftHandSideExpression
934 : NewExpression { $$ = $1; }
935 | CallExpression { $$ = $1; }
938 /* 11.3 Postfix Expressions {{{ */
940 : %prec "" LeftHandSideExpression { $$ = $1; }
941 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
942 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
945 /* 11.4 Unary Operators {{{ */
947 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
948 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
949 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
950 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
951 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
952 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
953 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
954 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
955 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
956 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
957 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
961 : PostfixExpression { $$ = $1; }
962 | LexSetRegExp UnaryExpression_ { $$ = $2; }
965 /* 11.5 Multiplicative Operators {{{ */
966 MultiplicativeExpression
967 : UnaryExpression { $$ = $1; }
968 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
969 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
970 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
973 /* 11.6 Additive Operators {{{ */
975 : MultiplicativeExpression { $$ = $1; }
976 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
977 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
980 /* 11.7 Bitwise Shift Operators {{{ */
982 : AdditiveExpression { $$ = $1; }
983 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
984 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
985 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
988 /* 11.8 Relational Operators {{{ */
990 : ShiftExpression { $$ = $1; }
991 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
992 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
993 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
994 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
995 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
996 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
999 /* 11.9 Equality Operators {{{ */
1001 : RelationalExpression { $$ = $1; }
1002 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1003 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1004 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1005 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1008 /* 11.10 Binary Bitwise Operators {{{ */
1009 BitwiseANDExpression
1010 : EqualityExpression { $$ = $1; }
1011 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1014 BitwiseXORExpression
1015 : BitwiseANDExpression { $$ = $1; }
1016 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1020 : BitwiseXORExpression { $$ = $1; }
1021 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1024 /* 11.11 Binary Logical Operators {{{ */
1025 LogicalANDExpression
1026 : BitwiseORExpression { $$ = $1; }
1027 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1031 : LogicalANDExpression { $$ = $1; }
1032 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1035 /* 11.12 Conditional Operator ( ? : ) {{{ */
1036 ConditionalExpression
1037 : LogicalORExpression { $$ = $1; }
1038 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1039 | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1042 /* 11.13 Assignment Operators {{{ */
1043 AssignmentExpression
1044 : ConditionalExpression { $$ = $1; }
1045 | ArrowFunction { $$ = $1; }
1046 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1047 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1048 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1049 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1050 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1051 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1052 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1053 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1054 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1055 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1056 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1057 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1060 /* 11.14 Comma Operator {{{ */
1062 : "," Expression { $$ = $2; }
1067 : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); }
1071 : Expression { $$ = $1; }
1072 | LexSetRegExp { $$ = NULL; }
1076 /* 12 Statements {{{ */
1078 : Block { $$ = $1; }
1079 | VariableStatement { $$ = $1; }
1080 | EmptyStatement { $$ = $1; }
1081 | IfStatement { $$ = $1; }
1082 | BreakableStatement { $$ = $1; }
1083 | ContinueStatement { $$ = $1; }
1084 | BreakStatement { $$ = $1; }
1085 | ReturnStatement { $$ = $1; }
1086 | WithStatement { $$ = $1; }
1087 | LabelledStatement { $$ = $1; }
1088 | ThrowStatement { $$ = $1; }
1089 | TryStatement { $$ = $1; }
1090 | DebuggerStatement { $$ = $1; }
1094 : LexSetRegExp Statement__ { $$ = $2; }
1095 | ExpressionStatement { $$ = $1; }
1099 : LexSetStatement Statement_ { $$ = $2; }
1103 : FunctionDeclaration { $$ = $1; }
1104 | LexicalDeclaration { $$ = $1; }
1108 : LexSetRegExp Declaration__ { $$ = $2; }
1112 : LexSetStatement Declaration_ { $$ = $2; }
1116 : IterationStatement { $$ = $1; }
1117 | SwitchStatement { $$ = $1; }
1120 /* 12.1 Block {{{ */
1122 : BRACE StatementListOpt "}" { $$ = $2; }
1126 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1130 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1134 : StatementList { $$ = $1; }
1135 | LexSetStatement LexSetRegExp { $$ = NULL; }
1139 : Statement { $$ = $1; }
1140 | Declaration { $$ = $1; }
1144 /* 12.2 Declarations {{{ */
1146 : Identifier { $$ = $1; }
1153 // XXX: BindingPattern
1155 /* 12.2.1 Let and Const Declarations {{{ */
1157 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1165 /* 12.2.2 Variable Statement {{{ */
1167 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1170 VariableDeclarationList_
1171 : "," VariableDeclarationList { $$ = $2; }
1175 VariableDeclarationList
1176 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1180 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1181 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1185 : "=" AssignmentExpression { $$ = $2; }
1189 : Initialiser { $$ = $1; }
1193 /* 12.2.4 Destructuring Binding Patterns {{{ */
1197 : SingleNameBinding { $$ = $1; }
1201 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1205 /* 12.3 Empty Statement {{{ */
1207 : ";" { $$ = CYNew CYEmpty(); }
1210 /* 12.4 Expression Statement {{{ */
1212 : Expression Terminator { $$ = CYNew CYExpress($1); }
1215 /* 12.5 The if Statement {{{ */
1217 : "else" Statement { $$ = $2; }
1218 | %prec "if" { $$ = NULL; }
1222 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1226 /* 12.6.1 The do-while Statement {{{ */
1228 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1231 /* 12.6.2 The while Statement {{{ */
1233 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1236 /* 12.6.3 The for Statement {{{ */
1238 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1241 ForStatementInitialiser
1242 : ExpressionOpt { $$ = $1; }
1243 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1246 /* 12.6.4 The for-in and for-of Statements {{{ */
1248 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1249 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1252 ForInStatementInitialiser
1253 : LeftHandSideExpression { $$ = $1; }
1254 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1258 /* 12.7 The continue Statement {{{ */
1260 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1261 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1264 /* 12.8 The break Statement {{{ */
1266 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1267 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1270 /* 12.9 The return Statement {{{ */
1272 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1273 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1276 /* 12.10 The with Statement {{{ */
1278 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1282 /* 12.11 The switch Statement {{{ */
1284 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1288 : BRACE CaseClausesOpt "}" { $$ = $2; }
1292 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1296 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1297 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1302 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1305 /* 12.12 Labelled Statements {{{ */
1307 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1310 /* 12.13 The throw Statement {{{ */
1312 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1313 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1316 /* 12.14 The try Statement {{{ */
1318 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1322 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1327 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1331 /* 12.14 The debugger Statement {{{ */
1333 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1337 /* 13.1 Function Definitions {{{ */
1339 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1343 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1346 FormalParameterList_
1347 : "," FormalParameterList { $$ = $2; }
1352 // XXX: : FunctionRestParameter { $$ = $1; }
1353 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1356 FormalParameterListOpt
1357 : FormalParameterList
1361 /* XXX: FunctionRestParameter
1362 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1366 : BindingElement { $$ = $1; }
1370 : StatementListOpt { $$ = $1; }
1373 /* 13.2 Arrow Function Definitions {{{ */
1375 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1379 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1380 //| ParentheticalOpt { $$ = $1; }
1384 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1385 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1388 /* 14 Program {{{ */
1390 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1394 : StatementList { $$ = $1; }
1398 : ProgramBody { $$ = $1; }
1399 | LexSetStatement LexSetRegExp { $$ = NULL; }
1404 /* Cycript (C): Type Encoding {{{ */
1406 : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1410 : IdentifierType { $$ = CYNew CYTypedIdentifier($1); }
1411 | TypeParenthetical { $$ = $1; }
1415 : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1416 | TypeSignifier { $$ = $1; }
1417 | { $$ = CYNew CYTypedIdentifier(); }
1421 : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); }
1425 : ArrayedType { $$ = $1; }
1426 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1427 | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1428 | IdentifierType FunctionedType { $$ = CYNew CYTypedIdentifier($1); CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1429 | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1433 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1438 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1439 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1443 : PrefixedType { $$ = $1; }
1444 | SuffixedType { $$ = $1; }
1445 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1446 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1450 : "int" { $$ = CYNew CYTypeVariable("int"); }
1451 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1452 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1453 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1454 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1458 : IntegerType { $$ = $1; }
1459 | { $$ = CYNew CYTypeVariable("int"); }
1463 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1464 | IntegerType { $$ = $1; }
1465 | "void" { $$ = CYNew CYTypeVoid(); }
1466 | "char" { $$ = CYNew CYTypeVariable("char"); }
1467 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1468 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1472 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1476 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1482 /* Cycript (Objective-C): @class Declaration {{{ */
1484 /* XXX: why the hell did I choose MemberExpression? */
1485 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1490 : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $3); }
1491 | LexSetRegExp { $$ = NULL; }
1495 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1499 : "+" { $$ = false; }
1500 | "-" { $$ = true; }
1504 : "(" LexSetRegExp TypedIdentifier ")" { $$ = $3; }
1509 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1512 MessageParameterList
1513 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1516 MessageParameterListOpt
1517 : MessageParameterList { $$ = $1; }
1522 : MessageParameterList { $$ = $1; }
1523 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1526 ClassMessageDeclaration
1527 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1530 ClassMessageDeclarationListOpt
1531 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1532 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1537 : Identifier { $$ = $1; }
1538 | "(" AssignmentExpression ")" { $$ = $2; }
1542 : ClassName { $$ = $1; }
1546 // XXX: this should be AssignmentExpressionNoRight
1548 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1552 : "," ClassProtocols { $$ = $2; }
1556 ClassProtocolListOpt
1557 : "<" ClassProtocols ">" { $$ = $2; }
1562 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1566 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1574 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1578 : ClassExpression { $$ = $1; }
1582 : ClassStatement { $$ = $1; }
1583 | CategoryStatement { $$ = $1; }
1586 /* Cycript (Objective-C): Send Message {{{ */
1588 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1593 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1594 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1598 : SelectorCall { $$ = $1; }
1599 | VariadicCall { $$ = $1; }
1603 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1607 : SelectorCall { $$ = $1; }
1608 | Word { $$ = CYNew CYArgument($1, NULL); }
1612 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1613 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1617 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1621 : SelectorExpression_ { $$ = $1; }
1622 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1625 SelectorExpressionOpt
1626 : SelectorExpression_ { $$ = $1; }
1631 : MessageExpression { $$ = $1; }
1632 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1637 /* Cycript: @import Directive {{{ */
1639 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1640 | Word { $$ = CYNew CYModule($1); }
1644 : "@import" Module { $$ = CYNew CYImport($2); }
1649 /* Cycript (Objective-C): Boxed Expressions {{{ */
1651 : NullLiteral { $$ = $1; }
1652 | BooleanLiteral { $$ = $1; }
1653 | NumericLiteral { $$ = $1; }
1654 | StringLiteral { $$ = $1; }
1655 | ArrayLiteral { $$ = $1; }
1656 | ObjectLiteral { $$ = $1; }
1657 | Parenthetical { $$ = $1; }
1658 | "YES" { $$ = CYNew CYTrue(); }
1659 | "NO" { $$ = CYNew CYFalse(); }
1663 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1666 /* Cycript (Objective-C): Block Expressions {{{ */
1668 : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->specifier_ = $2; $$->modifier_ = $1; }
1669 | ModifiedType "*" { $$ = $1; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1673 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1676 /* Cycript (Objective-C): Instance Literals {{{ */
1678 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
1684 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1685 LeftHandSideExpression
1686 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1690 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1694 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1695 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1696 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1699 /* Cycript (C): auto Compatibility {{{ */
1704 /* Cycript (C): Lambda Expressions {{{ */
1706 : "," TypedParameterList { $$ = $2; }
1711 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1714 TypedParameterListOpt
1715 : TypedParameterList { $$ = $1; }
1720 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1723 /* Cycript (C): Type Definitions {{{ */
1725 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) YYABORT; } Terminator { $$ = CYNew CYTypeDefinition($2); }
1728 /* Cycript (C): extern "C" {{{ */
1730 : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) YYABORT; } TypedIdentifier Terminator { $$ = CYNew CYExternal($2, $4); }
1736 /* YUI: Documentation Comments {{{ */
1738 : Comment { $$ = $1; }
1743 /* Lexer State {{{ */
1745 : { driver.PushCondition(CYDriver::RegExpCondition); }
1749 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1753 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1757 : { driver.PopCondition(); }
1761 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1765 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1768 /* Virtual Tokens {{{ */
1775 /* 8.1 Context Keywords {{{ */
1777 : "namespace" { $$ = $1; }
1778 | "xml" { $$ = $1; }
1781 /* 8.3 XML Initialiser Input Elements {{{ */
1783 : XMLComment { $$ = $1; }
1784 | XMLCDATA { $$ = $1; }
1785 | XMLPI { $$ = $1; }
1789 /* 11.1 Primary Expressions {{{ */
1791 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1792 | XMLInitialiser { $$ = $1; }
1793 | XMLListInitialiser { $$ = $1; }
1797 : AttributeIdentifier { $$ = $1; }
1798 | QualifiedIdentifier { $$ = $1; }
1799 | WildcardIdentifier { $$ = $1; }
1802 /* 11.1.1 Attribute Identifiers {{{ */
1804 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1808 : PropertySelector { $$ = $1; }
1809 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1813 : Identifier { $$ = CYNew CYSelector($1); }
1814 | WildcardIdentifier { $$ = $1; }
1817 /* 11.1.2 Qualified Identifiers {{{ */
1818 QualifiedIdentifier_
1819 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1820 | QualifiedIdentifier { $$ = $1; }
1824 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1827 /* 11.1.3 Wildcard Identifiers {{{ */
1829 : "*" { $$ = CYNew CYWildcard(); }
1832 /* 11.1.4 XML Initialiser {{{ */
1834 : XMLMarkup { $$ = $1; }
1835 | XMLElement { $$ = $1; }
1839 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1840 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1844 : LexPushXMLTag XMLTagName XMLAttributes
1848 : BRACE LexPushRegExp Expression LexPop "}"
1857 : XMLAttributes_ XMLAttribute
1862 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1863 | XMLAttributes_ XMLWhitespaceOpt
1872 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1876 : XMLExpression XMLElementContentOpt
1877 | XMLMarkup XMLElementContentOpt
1878 | XMLText XMLElementContentOpt
1879 | XMLElement XMLElementContentOpt
1882 XMLElementContentOpt
1887 /* 11.1.5 XMLList Initialiser {{{ */
1889 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1893 /* 11.2 Left-Hand-Side Expressions {{{ */
1895 : Identifier { $$ = $1; }
1896 | PropertyIdentifier { $$ = $1; }
1900 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1901 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1902 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1905 /* 12.1 The default xml namespace Statement {{{ */
1906 /* XXX: DefaultXMLNamespaceStatement
1907 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1911 : DefaultXMLNamespaceStatement { $$ = $1; }
1916 /* JavaScript 1.7: Array Comprehensions {{{ */
1918 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
1922 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1923 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1926 /* JavaScript 1.7: for each {{{ */
1928 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1931 /* JavaScript 1.7: let Statements {{{ */
1933 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1941 /* JavaScript FTW: Ruby Blocks {{{ */
1942 RubyProcParameterList_
1943 : "," RubyProcParameterList { $$ = $2; }
1947 RubyProcParameterList
1948 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1953 : "|" RubyProcParameterList "|" { $$ = $2; }
1954 | "||" { $$ = NULL; }
1957 RubyProcParametersOpt
1958 : RubyProcParameters
1963 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1967 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1971 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }