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 *, CYLocation *, void *);
121 @$.begin.filename = @$.end.filename = &driver.filename_;
127 %define api.location.type { CYLocation }
134 %parse-param { CYDriver &driver }
135 %lex-param { void *cyscanner }
137 /* Token Declarations {{{ */
143 %token XMLAttributeValue
145 %token XMLTagCharacters
151 %token LeftRight "<>"
152 %token LeftSlashRight "</>"
154 %token SlashRight "/>"
155 %token LeftSlash "</"
157 %token ColonColon "::"
158 %token PeriodPeriod ".."
161 @begin E4X ObjectiveC
167 %token AmpersandAmpersand "&&"
168 %token AmpersandEqual "&="
170 %token CarrotEqual "^="
172 %token EqualEqual "=="
173 %token EqualEqualEqual "==="
174 %token EqualRight "=>"
175 %token Exclamation "!"
176 %token ExclamationEqual "!="
177 %token ExclamationEqualEqual "!=="
179 %token HyphenEqual "-="
180 %token HyphenHyphen "--"
181 %token HyphenHyphen_ "\n--"
182 %token HyphenRight "->"
184 %token LeftEqual "<="
186 %token LeftLeftEqual "<<="
188 %token PercentEqual "%="
190 %token PeriodPeriodPeriod "..."
192 %token PipeEqual "|="
195 %token PlusEqual "+="
197 %token PlusPlus_ "\n++"
199 %token RightEqual ">="
200 %token RightRight ">>"
201 %token RightRightEqual ">>="
202 %token RightRightRight ">>>"
203 %token RightRightRightEqual ">>>="
205 %token SlashEqual "/="
207 %token StarEqual "*="
216 %token <comment_> Comment
219 %token CloseParen ")"
222 %token OpenBrace_ "\n{"
223 %token OpenBrace__ ";{"
224 %token CloseBrace "}"
226 %token OpenBracket "["
227 %token CloseBracket "]"
229 %token AtError "@error"
232 %token AtClass "@class"
236 %token <identifier_> Typedef "typedef"
237 %token <identifier_> Unsigned "unsigned"
238 %token <identifier_> Signed "signed"
239 %token <identifier_> Extern "extern"
243 %token AtEncode "@encode"
247 %token AtImplementation "@implementation"
248 %token AtImplementation_ ";@implementation"
249 %token AtImport "@import"
251 %token AtSelector "@selector"
252 %token <identifier_> Yes "YES"
253 %token <identifier_> No "NO"
256 %token <false_> False "false"
257 %token <null_> Null "null"
258 %token <true_> True "true"
260 // ES3/ES5/WIE/JSC Reserved
261 %token <word_> Auto "auto"
262 %token <word_> Break "break"
263 %token <word_> Case "case"
264 %token <word_> Catch "catch"
265 %token <word_> Continue "continue"
266 %token <word_> Default "default"
267 %token <word_> Delete "delete"
268 %token <word_> Do "do"
269 %token <word_> Else "else"
270 %token <word_> Finally "finally"
271 %token <word_> For "for"
272 %token <word_> Function "function"
273 %token <word_> Function_ ";function"
274 %token <word_> If "if"
275 %token <word_> In "in"
276 %token <word_> In_ "!in"
277 %token <word_> InstanceOf "instanceof"
278 %token <word_> New "new"
279 %token <word_> Return "return"
280 %token <word_> Switch "switch"
281 %token <this_> This "this"
282 %token <word_> Throw "throw"
283 %token <word_> Try "try"
284 %token <word_> TypeOf "typeof"
285 %token <word_> Var "var"
286 %token <word_> Void "void"
287 %token <word_> While "while"
288 %token <word_> With "with"
290 // ES3/IE6 Future, ES5/JSC Reserved
291 %token <word_> Debugger "debugger"
293 // ES3/ES5/IE6 Future, JSC Reserved
294 %token <word_> Const "const"
296 // ES3/ES5/IE6/JSC Future
297 %token <word_> Class "class"
298 %token <word_> Enum "enum"
299 %token <word_> Export "export"
300 %token <word_> Extends "extends"
301 %token <word_> Import "import"
302 %token <word_> Super "super"
304 // ES3 Future, ES5 Strict Future
305 %token <identifier_> Implements "implements"
306 %token <identifier_> Interface "interface"
307 %token <identifier_> Package "package"
308 %token <identifier_> Private "private"
309 %token <identifier_> Protected "protected"
310 %token <identifier_> Public "public"
311 %token <identifier_> Static "static"
314 %token <identifier_> Abstract "abstract"
315 %token <identifier_> Boolean "boolean"
316 %token <identifier_> Byte "byte"
317 %token <identifier_> Char "char"
318 %token <identifier_> Double "double"
319 %token <identifier_> Final "final"
320 %token <identifier_> Float "float"
321 %token <identifier_> Goto "goto"
322 %token <identifier_> Int "int"
323 %token <identifier_> Long "long"
324 %token <identifier_> Native "native"
325 %token <identifier_> Short "short"
326 %token <identifier_> Synchronized "synchronized"
327 %token <identifier_> Throws "throws"
328 %token <identifier_> Transient "transient"
329 %token <identifier_> Volatile "volatile"
332 %token <identifier_> Let "let"
333 %token <identifier_> Yield "yield"
336 %token <identifier_> Each "each"
337 %token <identifier_> Of "of"
341 %token <identifier_> Namespace "namespace"
342 %token <identifier_> XML "xml"
347 %token <identifier_> Identifier_
348 %token <number_> NumericLiteral
349 %token <string_> StringLiteral
350 %token <literal_> RegularExpressionLiteral
352 %type <expression_> AdditiveExpression
353 %type <argument_> ArgumentList_
354 %type <argument_> ArgumentList
355 %type <argument_> ArgumentListOpt
356 %type <argument_> Arguments
357 %type <expression_> ArrayComprehension
358 %type <expression_> ArrayInitialiser
359 %type <literal_> ArrayLiteral
360 %type <expression_> ArrowFunction
361 %type <functionParameter_> ArrowParameters
362 %type <expression_> AssignmentExpression
363 %type <identifier_> Binding
364 %type <identifier_> BindingIdentifier
365 %type <expression_> BitwiseANDExpression
366 %type <statement_> Block_
367 %type <statement_> Block
368 %type <boolean_> BooleanLiteral
369 %type <declaration_> BindingElement
370 %type <expression_> BitwiseORExpression
371 %type <expression_> BitwiseXORExpression
372 %type <statement_> BreakStatement
373 %type <statement_> BreakableStatement
374 %type <expression_> CallExpression_
375 %type <expression_> CallExpression
376 %type <clause_> CaseBlock
377 %type <clause_> CaseClause
378 %type <clause_> CaseClausesOpt
379 %type <catch_> CatchOpt
380 %type <expression_> Comprehension
381 %type <comprehension_> ComprehensionFor
382 %type <comprehension_> ComprehensionIf
383 %type <comprehension_> ComprehensionTail
384 %type <expression_> ConditionalExpression
385 %type <statement_> ContinueStatement
386 %type <statement_> ConciseBody
387 %type <statement_> DebuggerStatement
388 %type <statement_> Declaration__
389 %type <statement_> Declaration_
390 %type <statement_> Declaration
391 %type <clause_> DefaultClause
392 %type <expression_> Element
393 %type <expression_> ElementOpt
394 %type <element_> ElementList
395 %type <element_> ElementListOpt
396 %type <statement_> ElseStatementOpt
397 %type <statement_> EmptyStatement
398 %type <expression_> EqualityExpression
399 %type <compound_> Expression_
400 %type <compound_> Expression
401 %type <expression_> ExpressionOpt
402 %type <statement_> ExpressionStatement
403 %type <finally_> FinallyOpt
404 %type <for_> ForStatementInitialiser
405 %type <forin_> ForInStatementInitialiser
406 %type <declaration_> FormalParameter
407 %type <functionParameter_> FormalParameterList_
408 %type <functionParameter_> FormalParameterList
409 %type <functionParameter_> FormalParameterListOpt
410 %type <statement_> FunctionBody
411 %type <statement_> FunctionDeclaration
412 %type <expression_> FunctionExpression
413 %type <identifier_> Identifier
414 %type <identifier_> IdentifierOpt
415 %type <identifier_> IdentifierType
416 %type <word_> IdentifierName
417 %type <statement_> IfStatement
418 %type <expression_> Initialiser
419 %type <expression_> InitialiserOpt
420 %type <statement_> IterationStatement
421 %type <statement_> LabelledStatement
422 %type <expression_> LeftHandSideExpression
423 %type <statement_> LetStatement
424 %type <statement_> LexicalDeclaration
425 %type <literal_> Literal
426 %type <literal_> ValueLiteral
427 %type <expression_> LogicalANDExpression
428 %type <expression_> LogicalORExpression
429 %type <member_> MemberAccess
430 %type <expression_> MemberExpression_
431 %type <expression_> MemberExpression
432 %type <module_> Module
433 %type <expression_> MultiplicativeExpression
434 %type <expression_> NewExpression
435 %type <null_> NullLiteral
436 %type <literal_> ObjectLiteral
437 %type <compound_> Parenthetical
438 //%type <compound_> ParentheticalOpt
439 %type <expression_> PostfixExpression
440 %type <expression_> PrimaryExpression
441 %type <statement_> Program
442 %type <statement_> ProgramBody
443 %type <statement_> ProgramBodyOpt
444 %type <propertyName_> PropertyName_
445 %type <propertyName_> PropertyName
446 %type <property_> PropertyDefinition
447 %type <property_> PropertyDefinitionList_
448 %type <property_> PropertyDefinitionList
449 %type <property_> PropertyDefinitionListOpt
450 %type <expression_> RelationalExpression
451 %type <statement_> ReturnStatement
452 %type <rubyProc_> RubyProcExpression
453 %type <functionParameter_> RubyProcParameterList_
454 %type <functionParameter_> RubyProcParameterList
455 %type <functionParameter_> RubyProcParameters
456 %type <functionParameter_> RubyProcParametersOpt
457 %type <expression_> ShiftExpression
458 %type <declaration_> SingleNameBinding
459 %type <statement_> Statement__
460 %type <statement_> Statement_
461 %type <statement_> Statement
462 %type <statement_> StatementList
463 %type <statement_> StatementListOpt
464 %type <statement_> StatementListItem
465 %type <statement_> SwitchStatement
466 %type <statement_> ThrowStatement
467 %type <statement_> TryStatement
468 %type <expression_> UnaryExpression_
469 %type <expression_> UnaryExpression
470 %type <declaration_> VariableDeclaration
471 %type <declarations_> VariableDeclarationList_
472 %type <declarations_> VariableDeclarationList
473 %type <statement_> VariableStatement
474 %type <statement_> WithStatement
476 %type <word_> WordOpt
477 %type <expression_> Variable
480 %type <specifier_> IntegerType
481 %type <specifier_> IntegerTypeOpt
482 %type <typedIdentifier_> PrefixedType
483 %type <specifier_> PrimitiveType
484 %type <typedIdentifier_> SuffixedType
485 %type <typedIdentifier_> TypeSignifier
486 %type <modifier_> TypeQualifierLeft
487 %type <typedIdentifier_> TypeQualifierRight
488 %type <typedIdentifier_> TypedIdentifier
489 %type <typedParameter_> TypedParameterList_
490 %type <typedParameter_> TypedParameterList
491 %type <typedParameter_> TypedParameterListOpt
495 %type <expression_> BoxableExpression
496 %type <statement_> CategoryStatement
497 %type <expression_> ClassExpression
498 %type <field_> ClassFieldListOpt
499 %type <field_> ClassFields
500 %type <statement_> ClassStatement
501 %type <expression_> ClassSuperOpt
502 %type <message_> ClassMessageDeclaration
503 %type <message_> ClassMessageDeclarationListOpt
504 %type <className_> ClassName
505 %type <className_> ClassNameOpt
506 %type <protocol_> ClassProtocolListOpt
507 %type <protocol_> ClassProtocols
508 %type <protocol_> ClassProtocolsOpt
509 %type <expression_> MessageExpression
510 %type <messageParameter_> MessageParameter
511 %type <messageParameter_> MessageParameters
512 %type <messageParameter_> MessageParameterList
513 %type <messageParameter_> MessageParameterListOpt
514 %type <bool_> MessageScope
515 %type <argument_> SelectorCall_
516 %type <argument_> SelectorCall
517 %type <selector_> SelectorExpression_
518 %type <selector_> SelectorExpression
519 %type <selector_> SelectorExpressionOpt
520 %type <argument_> SelectorList
521 %type <word_> SelectorWordOpt
522 %type <typedIdentifier_> TypeOpt
523 %type <argument_> VariadicCall
527 %type <propertyIdentifier_> PropertyIdentifier_
528 %type <selector_> PropertySelector_
529 %type <selector_> PropertySelector
530 %type <identifier_> QualifiedIdentifier_
531 %type <identifier_> QualifiedIdentifier
532 %type <identifier_> WildcardIdentifier
533 %type <identifier_> XMLComment
534 %type <identifier_> XMLCDATA
535 %type <identifier_> XMLElement
536 %type <identifier_> XMLElementContent
537 %type <identifier_> XMLMarkup
538 %type <identifier_> XMLPI
540 %type <attribute_> AttributeIdentifier
541 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
542 %type <expression_> PropertyIdentifier
543 %type <expression_> XMLListInitialiser
544 %type <expression_> XMLInitialiser
547 /* Token Priorities {{{ */
559 /* Lexer State {{{ */
561 : { driver.in_.push(true); }
565 : { driver.in_.push(false); }
569 : { driver.in_.pop(); }
573 : { driver.SetCondition(CYDriver::RegExpCondition); }
577 : { if (yyla.empty()) driver.no_.OpenBrace = true; else if (yyla.type == yytranslate_(token::OpenBrace) || yyla.type == yytranslate_(token::OpenBrace_)) yyla.type = yytranslate_(token::OpenBrace__); }
581 : { if (yyla.empty()) driver.no_.Function = true; else if (yyla.type == yytranslate_(token::Function)) yyla.type = yytranslate_(token::Function_); }
584 LexNoAtImplementation :
586 { if (yyla.empty()) driver.no_.AtImplementation = true; else if (yyla.type == yytranslate_(token::AtImplementation)) yyla.type = yytranslate_(token::AtImplementation_); }
591 : LexNoBrace LexNoFunction LexNoAtImplementation
594 /* Virtual Tokens {{{ */
605 /* 7.6 Identifier Names and Identifiers {{{ */
616 : Identifier { $$ = $1; }
617 | "auto" { $$ = $1; }
618 | "break" NewLineOpt { $$ = $1; }
619 | "case" { $$ = $1; }
620 | "catch" { $$ = $1; }
621 | "class" { $$ = $1; }
622 | "const" { $$ = $1; }
623 | "continue" NewLineOpt { $$ = $1; }
624 | "debugger" { $$ = $1; }
625 | "default" { $$ = $1; }
626 | "delete" { $$ = $1; }
628 | "else" { $$ = $1; }
629 | "enum" { $$ = $1; }
630 | "export" { $$ = $1; }
631 | "extends" { $$ = $1; }
632 | "false" { $$ = $1; }
633 | "finally" { $$ = $1; }
634 /* XXX: | "for" { $$ = $1; } */
635 | "function" { $$ = $1; }
637 | "import" { $$ = $1; }
638 /* XXX: | "in" { $$ = $1; } */
640 /* XXX: | "instanceof" { $$ = $1; } */
642 // XXX: as it currently is not an Identifier
646 | "null" { $$ = $1; }
647 | "return" NewLineOpt { $$ = $1; }
648 | "super" { $$ = $1; }
649 | "switch" { $$ = $1; }
650 | "this" { $$ = $1; }
651 | "throw" NewLineOpt { $$ = $1; }
652 | "true" { $$ = $1; }
654 | "typeof" { $$ = $1; }
656 | "void" { $$ = $1; }
657 | "while" { $$ = $1; }
658 | "with" { $$ = $1; }
667 : Identifier_ { $$ = $1; }
669 | "implements" { $$ = $1; }
670 | "interface" { $$ = $1; }
671 | "package" { $$ = $1; }
672 | "private" { $$ = $1; }
673 | "protected" { $$ = $1; }
674 | "public" { $$ = $1; }
675 | "static" { $$ = $1; }
677 | "abstract" { $$ = $1; }
678 | "boolean" { $$ = $1; }
679 | "byte" { $$ = $1; }
680 | "double" { $$ = $1; }
681 | "final" { $$ = $1; }
682 | "float" { $$ = $1; }
683 | "goto" { $$ = $1; }
684 | "native" { $$ = $1; }
685 | "synchronized" { $$ = $1; }
686 | "throws" { $$ = $1; }
687 | "transient" { $$ = $1; }
689 // XXX: currently I only have this as Word
690 // | "let" { $$ = $1; }
692 | "yield" { $$ = $1; }
694 | "each" { $$ = $1; }
700 | "char" { $$ = $1; }
702 | "long" { $$ = $1; }
703 | "short" { $$ = $1; }
704 | "volatile" { $$ = $1; }
706 | "typedef" { $$ = $1; }
707 | "unsigned" { $$ = $1; }
708 | "signed" { $$ = $1; }
709 | "extern" { $$ = $1; }
718 : Identifier { $$ = $1; }
723 /* 7.8 Literals {{{ */
725 : NullLiteral { $$ = $1; }
726 | ValueLiteral { $$ = $1; }
730 : BooleanLiteral { $$ = $1; }
731 | NumericLiteral { $$ = $1; }
732 | StringLiteral { $$ = $1; }
733 | RegularExpressionLiteral { $$ = $1; }
736 /* 7.8.1 Null Literals {{{ */
738 : "null" { $$ = $1; }
741 /* 7.8.2 Boolean Literals {{{ */
743 : "true" { $$ = $1; }
744 | "false" { $$ = $1; }
748 /* 7.9 Automatic Semicolon Insertion {{{ */
750 : { driver.Warning(@$, "warning, automatic semi-colon insertion required"); }
755 | error { if (yyla.type_get() != yyeof_ && yyla.type != token::CloseBrace && !yyla.value.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
760 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
764 /* 11.1 Primary Expressions {{{ */
766 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
770 : Parenthetical { $$ = $1; }
775 : Identifier { $$ = CYNew CYVariable($1); }
779 : "this" { $$ = $1; }
780 | Variable { $$ = $1; }
781 | Literal { $$ = $1; }
782 | ArrayInitialiser { $$ = $1; }
783 | ObjectLiteral { $$ = $1; }
784 | Parenthetical { $$ = $1; }
785 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
788 /* 11.1.4 Array Initializer {{{ */
790 : ArrayLiteral { $$ = $1; }
791 | ArrayComprehension { $$ = $1; }
794 /* 11.1.4.1 Array Literal {{{ */
796 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
800 : AssignmentExpression { $$ = $1; }
804 : Element { $$ = $1; }
805 | LexSetRegExp { $$ = NULL; }
809 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
810 | Element { $$ = CYNew CYElement($1, NULL); }
814 : ElementList { $$ = $1; }
815 | LexSetRegExp { $$ = NULL; }
818 /* 11.1.4.2 Array Comprehension {{{ */
820 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
824 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
829 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
830 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
834 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
838 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
841 /* 11.1.5 Object Initialiser {{{ */
843 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
846 PropertyDefinitionList_
847 : "," PropertyDefinitionList { $$ = $2; }
848 | "," LexSetRegExp { $$ = NULL; }
852 PropertyDefinitionList
853 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
856 PropertyDefinitionListOpt
857 : PropertyDefinitionList { $$ = $1; }
858 | LexSetRegExp { $$ = NULL; }
862 // XXX: this should be IdentifierName
863 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
864 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
869 : IdentifierName { $$ = $1; }
870 | StringLiteral { $$ = $1; }
871 | NumericLiteral { $$ = $1; }
875 : LexSetRegExp PropertyName_ { $$ = $2; }
879 /* 11.2 Left-Hand-Side Expressions {{{ */
881 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
882 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
883 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
887 : MemberExpression { $$ = $1; }
888 //| "super" { $$ = $1; }
892 : LexSetRegExp PrimaryExpression { $$ = $2; }
893 | LexSetRegExp FunctionExpression { $$ = $2; }
894 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
895 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
899 : MemberExpression { $$ = $1; }
900 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
909 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
910 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
914 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
918 : "," ArgumentList { $$ = $2; }
923 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
927 : ArgumentList { $$ = $1; }
928 | LexSetRegExp { $$ = NULL; }
931 LeftHandSideExpression
932 : NewExpression { $$ = $1; }
933 | CallExpression { $$ = $1; }
936 /* 11.3 Postfix Expressions {{{ */
938 : %prec "" LeftHandSideExpression { $$ = $1; }
939 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
940 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
943 /* 11.4 Unary Operators {{{ */
945 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
946 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
947 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
948 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
949 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
950 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
951 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
952 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
953 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
954 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
955 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
959 : PostfixExpression { $$ = $1; }
960 | LexSetRegExp UnaryExpression_ { $$ = $2; }
963 /* 11.5 Multiplicative Operators {{{ */
964 MultiplicativeExpression
965 : UnaryExpression { $$ = $1; }
966 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
967 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
968 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
971 /* 11.6 Additive Operators {{{ */
973 : MultiplicativeExpression { $$ = $1; }
974 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
975 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
978 /* 11.7 Bitwise Shift Operators {{{ */
980 : AdditiveExpression { $$ = $1; }
981 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
982 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
983 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
986 /* 11.8 Relational Operators {{{ */
988 : ShiftExpression { $$ = $1; }
989 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
990 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
991 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
992 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
993 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
994 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
997 /* 11.9 Equality Operators {{{ */
999 : RelationalExpression { $$ = $1; }
1000 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
1001 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
1002 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
1003 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
1006 /* 11.10 Binary Bitwise Operators {{{ */
1007 BitwiseANDExpression
1008 : EqualityExpression { $$ = $1; }
1009 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
1012 BitwiseXORExpression
1013 : BitwiseANDExpression { $$ = $1; }
1014 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1018 : BitwiseXORExpression { $$ = $1; }
1019 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1022 /* 11.11 Binary Logical Operators {{{ */
1023 LogicalANDExpression
1024 : BitwiseORExpression { $$ = $1; }
1025 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1029 : LogicalANDExpression { $$ = $1; }
1030 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1033 /* 11.12 Conditional Operator ( ? : ) {{{ */
1034 ConditionalExpression
1035 : LogicalORExpression { $$ = $1; }
1036 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1037 | LogicalORExpression "?" LexPushInOff LexSetRegExp ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $1, $7); }
1040 /* 11.13 Assignment Operators {{{ */
1041 AssignmentExpression
1042 : ConditionalExpression { $$ = $1; }
1043 | ArrowFunction { $$ = $1; }
1044 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1045 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1046 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1047 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1048 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1049 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1050 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1051 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1052 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1053 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1054 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1055 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1058 /* 11.14 Comma Operator {{{ */
1060 : "," Expression { $$ = $2; }
1065 : AssignmentExpression Expression_ { $$ = CYNew CYCompound($1, $2); }
1069 : Expression { $$ = $1; }
1070 | LexSetRegExp { $$ = NULL; }
1074 /* 12 Statements {{{ */
1076 : Block { $$ = $1; }
1077 | VariableStatement { $$ = $1; }
1078 | EmptyStatement { $$ = $1; }
1079 | IfStatement { $$ = $1; }
1080 | BreakableStatement { $$ = $1; }
1081 | ContinueStatement { $$ = $1; }
1082 | BreakStatement { $$ = $1; }
1083 | ReturnStatement { $$ = $1; }
1084 | WithStatement { $$ = $1; }
1085 | LabelledStatement { $$ = $1; }
1086 | ThrowStatement { $$ = $1; }
1087 | TryStatement { $$ = $1; }
1088 | DebuggerStatement { $$ = $1; }
1092 : LexSetRegExp Statement__ { $$ = $2; }
1093 | ExpressionStatement { $$ = $1; }
1097 : LexSetStatement Statement_ { $$ = $2; }
1101 : FunctionDeclaration { $$ = $1; }
1102 | LexicalDeclaration { $$ = $1; }
1106 : LexSetRegExp Declaration__ { $$ = $2; }
1110 : LexSetStatement Declaration_ { $$ = $2; }
1114 : IterationStatement { $$ = $1; }
1115 | SwitchStatement { $$ = $1; }
1118 /* 12.1 Block {{{ */
1120 : BRACE StatementListOpt "}" { $$ = $2; }
1124 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1128 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1132 : StatementList { $$ = $1; }
1133 | LexSetStatement LexSetRegExp { $$ = NULL; }
1137 : Statement { $$ = $1; }
1138 | Declaration { $$ = $1; }
1142 /* 12.2 Declarations {{{ */
1144 : Identifier { $$ = $1; }
1151 // XXX: BindingPattern
1153 /* 12.2.1 Let and Const Declarations {{{ */
1155 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1163 /* 12.2.2 Variable Statement {{{ */
1165 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1168 VariableDeclarationList_
1169 : "," VariableDeclarationList { $$ = $2; }
1173 VariableDeclarationList
1174 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1178 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1179 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1183 : "=" AssignmentExpression { $$ = $2; }
1187 : Initialiser { $$ = $1; }
1191 /* 12.2.4 Destructuring Binding Patterns {{{ */
1195 : SingleNameBinding { $$ = $1; }
1199 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1203 /* 12.3 Empty Statement {{{ */
1205 : ";" { $$ = CYNew CYEmpty(); }
1208 /* 12.4 Expression Statement {{{ */
1210 : Expression Terminator { $$ = CYNew CYExpress($1); }
1213 /* 12.5 The if Statement {{{ */
1215 : "else" Statement { $$ = $2; }
1216 | %prec "if" { $$ = NULL; }
1220 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1224 /* 12.6.1 The do-while Statement {{{ */
1226 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1229 /* 12.6.2 The while Statement {{{ */
1231 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1234 /* 12.6.3 The for Statement {{{ */
1236 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1239 ForStatementInitialiser
1240 : ExpressionOpt { $$ = $1; }
1241 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1244 /* 12.6.4 The for-in and for-of Statements {{{ */
1246 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1247 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1250 ForInStatementInitialiser
1251 : LeftHandSideExpression { $$ = $1; }
1252 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1256 /* 12.7 The continue Statement {{{ */
1258 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1259 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1262 /* 12.8 The break Statement {{{ */
1264 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1265 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1268 /* 12.9 The return Statement {{{ */
1270 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1271 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1274 /* 12.10 The with Statement {{{ */
1276 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1280 /* 12.11 The switch Statement {{{ */
1282 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1286 : BRACE CaseClausesOpt "}" { $$ = $2; }
1290 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1294 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1295 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1300 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1303 /* 12.12 Labelled Statements {{{ */
1305 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1308 /* 12.13 The throw Statement {{{ */
1310 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1311 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1314 /* 12.14 The try Statement {{{ */
1316 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1320 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1325 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1329 /* 12.14 The debugger Statement {{{ */
1331 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1335 /* 13.1 Function Definitions {{{ */
1337 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1341 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1344 FormalParameterList_
1345 : "," FormalParameterList { $$ = $2; }
1350 // XXX: : FunctionRestParameter { $$ = $1; }
1351 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1354 FormalParameterListOpt
1355 : FormalParameterList
1359 /* XXX: FunctionRestParameter
1360 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1364 : BindingElement { $$ = $1; }
1368 : StatementListOpt { $$ = $1; }
1371 /* 13.2 Arrow Function Definitions {{{ */
1373 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1377 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1378 //| ParentheticalOpt { $$ = $1; }
1382 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1383 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1386 /* 14 Program {{{ */
1388 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1392 : StatementList { $$ = $1; }
1396 : ProgramBody { $$ = $1; }
1397 | LexSetStatement LexSetRegExp { $$ = NULL; }
1402 /* Cycript (C): Type Encoding {{{ */
1404 : IdentifierType { $$ = CYNew CYTypedIdentifier(@1, $1); }
1405 | "(" LexPushInOff "*" TypeQualifierRight ")" LexPopIn { $$ = $4; }
1409 : SuffixedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1410 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1411 | TypeSignifier "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; $$->modifier_ = CYNew CYTypeFunctionWith($4, $$->modifier_); }
1412 | "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypedIdentifier(@1); $$->modifier_ = CYNew CYTypeFunctionWith($3, $$->modifier_); }
1413 | TypeSignifier { $$ = $1; }
1414 | { $$ = CYNew CYTypedIdentifier(@$); }
1418 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1423 | "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1424 | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); }
1428 : PrefixedType { $$ = $1; }
1429 | SuffixedType { $$ = $1; }
1430 | "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1431 | "volatile" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeVolatile($$->modifier_); }
1435 : "int" { $$ = CYNew CYTypeVariable("int"); }
1436 | "unsigned" IntegerTypeOpt { $$ = CYNew CYTypeUnsigned($2); }
1437 | "signed" IntegerTypeOpt { $$ = CYNew CYTypeSigned($2); }
1438 | "long" IntegerTypeOpt { $$ = CYNew CYTypeLong($2); }
1439 | "short" IntegerTypeOpt { $$ = CYNew CYTypeShort($2); }
1443 : IntegerType { $$ = $1; }
1444 | { $$ = CYNew CYTypeVariable("int"); }
1448 : IdentifierType { $$ = CYNew CYTypeVariable($1); }
1449 | IntegerType { $$ = $1; }
1450 | "void" { $$ = CYNew CYTypeVoid(); }
1451 | "char" { $$ = CYNew CYTypeVariable("char"); }
1452 | "signed" "char" { $$ = CYNew CYTypeSigned(CYNew CYTypeVariable("char")); }
1453 | "unsigned" "char" { $$ = CYNew CYTypeUnsigned(CYNew CYTypeVariable("char")); }
1457 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1461 : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
1467 /* Cycript (Objective-C): @class Declaration {{{ */
1469 /* XXX: why the hell did I choose MemberExpression? */
1470 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1475 : TypedIdentifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $3); }
1476 | LexSetRegExp { $$ = NULL; }
1480 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1484 : "+" { $$ = false; }
1485 | "-" { $$ = true; }
1489 : "(" LexSetRegExp TypedIdentifier ")" { $$ = $3; }
1494 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1497 MessageParameterList
1498 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1501 MessageParameterListOpt
1502 : MessageParameterList { $$ = $1; }
1507 : MessageParameterList { $$ = $1; }
1508 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1511 ClassMessageDeclaration
1512 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1515 ClassMessageDeclarationListOpt
1516 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1517 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1522 : Identifier { $$ = $1; }
1523 | "(" AssignmentExpression ")" { $$ = $2; }
1527 : ClassName { $$ = $1; }
1531 // XXX: this should be AssignmentExpressionNoRight
1533 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1537 : "," ClassProtocols { $$ = $2; }
1541 ClassProtocolListOpt
1542 : "<" ClassProtocols ">" { $$ = $2; }
1547 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1551 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1559 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1563 : ClassExpression { $$ = $1; }
1567 : ClassStatement { $$ = $1; }
1568 | CategoryStatement { $$ = $1; }
1571 /* Cycript (Objective-C): Send Message {{{ */
1573 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1578 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1579 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1583 : SelectorCall { $$ = $1; }
1584 | VariadicCall { $$ = $1; }
1588 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1592 : SelectorCall { $$ = $1; }
1593 | Word { $$ = CYNew CYArgument($1, NULL); }
1597 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1598 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1602 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1606 : SelectorExpression_ { $$ = $1; }
1607 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1610 SelectorExpressionOpt
1611 : SelectorExpression_ { $$ = $1; }
1616 : MessageExpression { $$ = $1; }
1617 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1622 /* Cycript: @import Directive {{{ */
1624 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1625 | Word { $$ = CYNew CYModule($1); }
1629 : "@import" Module { $$ = CYNew CYImport($2); }
1634 /* Cycript (Objective-C): Boxed Expressions {{{ */
1636 : NullLiteral { $$ = $1; }
1637 | BooleanLiteral { $$ = $1; }
1638 | NumericLiteral { $$ = $1; }
1639 | StringLiteral { $$ = $1; }
1640 | ArrayLiteral { $$ = $1; }
1641 | ObjectLiteral { $$ = $1; }
1642 | Parenthetical { $$ = $1; }
1643 | "YES" { $$ = CYNew CYTrue(); }
1644 | "NO" { $$ = CYNew CYFalse(); }
1648 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1651 /* Cycript (Objective-C): Block Expressions {{{ */
1653 : "^" TypedIdentifier { if ($2->identifier_ != NULL) error($2->location_, "unexpected identifier"); } BRACE LexPushInOff FunctionBody "}" LexPopIn { if (CYTypeFunctionWith *function = $2->Function()) $$ = CYNew CYObjCBlock($2, function->parameters_, $6); else error($2->location_, "expected parameters"); }
1656 /* Cycript (Objective-C): Instance Literals {{{ */
1658 : "#" NumericLiteral { $$ = CYNew CYInstanceLiteral($2); }
1664 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1665 LeftHandSideExpression
1666 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1670 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1674 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1675 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1676 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1679 /* Cycript (C): auto Compatibility {{{ */
1684 /* Cycript (C): Lambda Expressions {{{ */
1686 : "," TypedParameterList { $$ = $2; }
1691 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1694 TypedParameterListOpt
1695 : TypedParameterList { $$ = $1; }
1700 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1703 /* Cycript (C): Type Definitions {{{ */
1705 : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) error($2->location_, "expected identifier"); } Terminator { $$ = CYNew CYTypeDefinition($2); }
1708 /* Cycript (C): extern "C" {{{ */
1710 : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) YYABORT; } TypedIdentifier { if ($4->identifier_ == NULL) error($4->location_, "expected identifier"); } Terminator { $$ = CYNew CYExternal($2, $4); }
1716 /* YUI: Documentation Comments {{{ */
1718 : Comment { $$ = $1; }
1723 /* Lexer State {{{ */
1725 : { driver.PushCondition(CYDriver::RegExpCondition); }
1729 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1733 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1737 : { driver.PopCondition(); }
1741 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1745 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1748 /* Virtual Tokens {{{ */
1755 /* 8.1 Context Keywords {{{ */
1757 : "namespace" { $$ = $1; }
1758 | "xml" { $$ = $1; }
1761 /* 8.3 XML Initialiser Input Elements {{{ */
1763 : XMLComment { $$ = $1; }
1764 | XMLCDATA { $$ = $1; }
1765 | XMLPI { $$ = $1; }
1769 /* 11.1 Primary Expressions {{{ */
1771 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1772 | XMLInitialiser { $$ = $1; }
1773 | XMLListInitialiser { $$ = $1; }
1777 : AttributeIdentifier { $$ = $1; }
1778 | QualifiedIdentifier { $$ = $1; }
1779 | WildcardIdentifier { $$ = $1; }
1782 /* 11.1.1 Attribute Identifiers {{{ */
1784 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1788 : PropertySelector { $$ = $1; }
1789 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1793 : Identifier { $$ = CYNew CYSelector($1); }
1794 | WildcardIdentifier { $$ = $1; }
1797 /* 11.1.2 Qualified Identifiers {{{ */
1798 QualifiedIdentifier_
1799 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1800 | QualifiedIdentifier { $$ = $1; }
1804 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1807 /* 11.1.3 Wildcard Identifiers {{{ */
1809 : "*" { $$ = CYNew CYWildcard(); }
1812 /* 11.1.4 XML Initialiser {{{ */
1814 : XMLMarkup { $$ = $1; }
1815 | XMLElement { $$ = $1; }
1819 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1820 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1824 : LexPushXMLTag XMLTagName XMLAttributes
1828 : BRACE LexPushRegExp Expression LexPop "}"
1837 : XMLAttributes_ XMLAttribute
1842 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1843 | XMLAttributes_ XMLWhitespaceOpt
1852 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1856 : XMLExpression XMLElementContentOpt
1857 | XMLMarkup XMLElementContentOpt
1858 | XMLText XMLElementContentOpt
1859 | XMLElement XMLElementContentOpt
1862 XMLElementContentOpt
1867 /* 11.1.5 XMLList Initialiser {{{ */
1869 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1873 /* 11.2 Left-Hand-Side Expressions {{{ */
1875 : Identifier { $$ = $1; }
1876 | PropertyIdentifier { $$ = $1; }
1880 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1881 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1882 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1885 /* 12.1 The default xml namespace Statement {{{ */
1886 /* XXX: DefaultXMLNamespaceStatement
1887 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1891 : DefaultXMLNamespaceStatement { $$ = $1; }
1896 /* JavaScript 1.7: Array Comprehensions {{{ */
1898 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
1902 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1903 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1906 /* JavaScript 1.7: for each {{{ */
1908 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1911 /* JavaScript 1.7: let Statements {{{ */
1913 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1921 /* JavaScript FTW: Ruby Blocks {{{ */
1922 RubyProcParameterList_
1923 : "," RubyProcParameterList { $$ = $2; }
1927 RubyProcParameterList
1928 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1933 : "|" RubyProcParameterList "|" { $$ = $2; }
1934 | "||" { $$ = NULL; }
1937 RubyProcParametersOpt
1938 : RubyProcParameters
1943 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1947 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1951 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }