1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2013 Jay Freeman (saurik)
5 /* GNU General Public License, Version 3 {{{ */
7 * Cycript is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
12 * Cycript is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Cycript. If not, see <http://www.gnu.org/licenses/>.
24 @if Bison24 %code top {
25 #define cyscanner driver.scanner_
26 #define YYSTACKEXPANDABLE 1
27 @if Bison23 #define yyerrok (yyerrstatus_ = 0)
30 @if Bison24 %code requires {
33 #define CYNew new($pool)
36 #include "ObjectiveC/Syntax.hpp"
40 #include "E4X/Syntax.hpp"
43 #include "Highlight.hpp"
52 CYDriver::Condition condition_;
54 CYArgument *argument_;
55 CYAssignment *assignment_;
58 cy::Syntax::Catch *catch_;
60 CYComprehension *comprehension_;
61 CYCompound *compound_;
62 CYDeclaration *declaration_;
63 CYDeclarations *declarations_;
65 CYExpression *expression_;
68 CYForInitialiser *for_;
69 CYForInInitialiser *forin_;
70 CYFunctionParameter *functionParameter_;
71 CYIdentifier *identifier_;
79 CYProperty *property_;
80 CYPropertyName *propertyName_;
81 CYRubyProc *rubyProc_;
82 CYStatement *statement_;
89 CYClassName *className_;
92 CYMessageParameter *messageParameter_;
93 CYProtocol *protocol_;
94 CYSelectorPart *selector_;
95 CYTypeModifier *modifier_;
96 CYTypedIdentifier *typedIdentifier_;
97 CYTypedParameter *typedParameter_;
101 CYAttribute *attribute_;
102 CYPropertyIdentifier *propertyIdentifier_;
103 CYSelector *selector_;
108 #define YYSTYPE YYSTYPE
111 @if Bison24 %code provides {
112 int cylex(YYSTYPE *, cy::location *, void *);
119 @if Bison23 %skeleton "lalr1.cc"
120 @if Bison24 %language "C++"
123 @$.begin.filename = @$.end.filename = &driver.filename_;
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
166 %token AmpersandAmpersand "&&"
167 %token AmpersandEqual "&="
169 %token CarrotEqual "^="
171 %token EqualEqual "=="
172 %token EqualEqualEqual "==="
173 %token EqualRight "=>"
174 %token Exclamation "!"
175 %token ExclamationEqual "!="
176 %token ExclamationEqualEqual "!=="
178 %token HyphenEqual "-="
179 %token HyphenHyphen "--"
180 %token HyphenHyphen_ "\n--"
181 %token HyphenRight "->"
183 %token LeftEqual "<="
185 %token LeftLeftEqual "<<="
187 %token PercentEqual "%="
189 %token PeriodPeriodPeriod "..."
191 %token PipeEqual "|="
194 %token PlusEqual "+="
196 %token PlusPlus_ "\n++"
198 %token RightEqual ">="
199 %token RightRight ">>"
200 %token RightRightEqual ">>="
201 %token RightRightRight ">>>"
202 %token RightRightRightEqual ">>>="
204 %token SlashEqual "/="
206 %token StarEqual "*="
215 %token <comment_> Comment
218 %token CloseParen ")"
221 %token OpenBrace_ "\n{"
222 %token OpenBrace__ ";{"
223 %token CloseBrace "}"
225 %token OpenBracket "["
226 %token CloseBracket "]"
228 %token AtError "@error"
231 %token AtClass "@class"
235 %token <identifier_> Typedef "typedef"
239 %token AtImplementation "@implementation"
240 %token AtImplementation_ ";@implementation"
241 %token AtImport "@import"
242 %token AtEncode "@encode"
244 %token AtSelector "@selector"
245 %token <identifier_> Yes "YES"
246 %token <identifier_> No "NO"
249 %token <false_> False "false"
250 %token <null_> Null "null"
251 %token <true_> True "true"
253 // ES3/ES5/WIE/JSC Reserved
254 %token <word_> Auto "auto"
255 %token <word_> Break "break"
256 %token <word_> Case "case"
257 %token <word_> Catch "catch"
258 %token <word_> Continue "continue"
259 %token <word_> Default "default"
260 %token <word_> Delete "delete"
261 %token <word_> Do "do"
262 %token <word_> Else "else"
263 %token <word_> Finally "finally"
264 %token <word_> For "for"
265 %token <word_> Function "function"
266 %token <word_> Function_ ";function"
267 %token <word_> If "if"
268 %token <word_> In "in"
269 %token <word_> In_ "!in"
270 %token <word_> InstanceOf "instanceof"
271 %token <word_> New "new"
272 %token <word_> Return "return"
273 %token <word_> Switch "switch"
274 %token <this_> This "this"
275 %token <word_> Throw "throw"
276 %token <word_> Try "try"
277 %token <word_> TypeOf "typeof"
278 %token <word_> Var "var"
279 %token <word_> Void "void"
280 %token <word_> While "while"
281 %token <word_> With "with"
283 // ES3/IE6 Future, ES5/JSC Reserved
284 %token <word_> Debugger "debugger"
286 // ES3/ES5/IE6 Future, JSC Reserved
287 %token <word_> Const "const"
289 // ES3/ES5/IE6/JSC Future
290 %token <word_> Class "class"
291 %token <word_> Enum "enum"
292 %token <word_> Export "export"
293 %token <word_> Extends "extends"
294 %token <word_> Import "import"
295 %token <word_> Super "super"
297 // ES3 Future, ES5 Strict Future
298 %token <identifier_> Implements "implements"
299 %token <identifier_> Interface "interface"
300 %token <identifier_> Package "package"
301 %token <identifier_> Private "private"
302 %token <identifier_> Protected "protected"
303 %token <identifier_> Public "public"
304 %token <identifier_> Static "static"
307 %token <identifier_> Abstract "abstract"
308 %token <identifier_> Boolean "boolean"
309 %token <identifier_> Byte "byte"
310 %token <identifier_> Char "char"
311 %token <identifier_> Double "double"
312 %token <identifier_> Final "final"
313 %token <identifier_> Float "float"
314 %token <identifier_> Goto "goto"
315 %token <identifier_> Int "int"
316 %token <identifier_> Long "long"
317 %token <identifier_> Native "native"
318 %token <identifier_> Short "short"
319 %token <identifier_> Synchronized "synchronized"
320 %token <identifier_> Throws "throws"
321 %token <identifier_> Transient "transient"
322 %token <identifier_> Volatile "volatile"
325 %token <identifier_> Let "let"
326 %token <identifier_> Yield "yield"
329 %token <identifier_> Each "each"
330 %token <identifier_> Of "of"
334 %token <identifier_> Namespace "namespace"
335 %token <identifier_> XML "xml"
340 %token <identifier_> Identifier_
341 %token <number_> NumericLiteral
342 %token <string_> StringLiteral
343 %token <literal_> RegularExpressionLiteral
345 %type <expression_> AdditiveExpression
346 %type <argument_> ArgumentList_
347 %type <argument_> ArgumentList
348 %type <argument_> ArgumentListOpt
349 %type <argument_> Arguments
350 %type <expression_> ArrayComprehension
351 %type <expression_> ArrayInitialiser
352 %type <literal_> ArrayLiteral
353 %type <expression_> ArrowFunction
354 %type <functionParameter_> ArrowParameters
355 %type <expression_> AssignmentExpression
356 %type <identifier_> Binding
357 %type <identifier_> BindingIdentifier
358 %type <expression_> BitwiseANDExpression
359 %type <statement_> Block_
360 %type <statement_> Block
361 %type <boolean_> BooleanLiteral
362 %type <declaration_> BindingElement
363 %type <expression_> BitwiseORExpression
364 %type <expression_> BitwiseXORExpression
365 %type <statement_> BreakStatement
366 %type <statement_> BreakableStatement
367 %type <expression_> CallExpression_
368 %type <expression_> CallExpression
369 %type <clause_> CaseBlock
370 %type <clause_> CaseClause
371 %type <clause_> CaseClausesOpt
372 %type <catch_> CatchOpt
373 %type <expression_> Comprehension
374 %type <comprehension_> ComprehensionFor
375 %type <comprehension_> ComprehensionIf
376 %type <comprehension_> ComprehensionTail
377 %type <expression_> ConditionalExpression
378 %type <statement_> ContinueStatement
379 %type <statement_> ConciseBody
380 %type <statement_> DebuggerStatement
381 %type <statement_> Declaration__
382 %type <statement_> Declaration_
383 %type <statement_> Declaration
384 %type <clause_> DefaultClause
385 %type <expression_> Element
386 %type <expression_> ElementOpt
387 %type <element_> ElementList
388 %type <element_> ElementListOpt
389 %type <statement_> ElseStatementOpt
390 %type <statement_> EmptyStatement
391 %type <expression_> EqualityExpression
392 %type <compound_> Expression_
393 %type <compound_> Expression
394 %type <expression_> ExpressionOpt
395 %type <statement_> ExpressionStatement
396 %type <finally_> FinallyOpt
397 %type <for_> ForStatementInitialiser
398 %type <forin_> ForInStatementInitialiser
399 %type <declaration_> FormalParameter
400 %type <functionParameter_> FormalParameterList_
401 %type <functionParameter_> FormalParameterList
402 %type <functionParameter_> FormalParameterListOpt
403 %type <statement_> FunctionBody
404 %type <statement_> FunctionDeclaration
405 %type <expression_> FunctionExpression
406 %type <identifier_> Identifier
407 %type <identifier_> IdentifierOpt
408 %type <word_> IdentifierName
409 %type <statement_> IfStatement
410 %type <expression_> Initialiser
411 %type <expression_> InitialiserOpt
412 %type <statement_> IterationStatement
413 %type <statement_> LabelledStatement
414 %type <expression_> LeftHandSideExpression
415 %type <statement_> LetStatement
416 %type <statement_> LexicalDeclaration
417 %type <literal_> Literal
418 %type <literal_> ValueLiteral
419 %type <expression_> LogicalANDExpression
420 %type <expression_> LogicalORExpression
421 %type <member_> MemberAccess
422 %type <expression_> MemberExpression_
423 %type <expression_> MemberExpression
424 %type <expression_> MultiplicativeExpression
425 %type <expression_> NewExpression
426 %type <null_> NullLiteral
427 %type <literal_> ObjectLiteral
428 %type <compound_> Parenthetical
429 %type <compound_> ParentheticalOpt
430 %type <expression_> PostfixExpression
431 %type <expression_> PrimaryExpression
432 %type <statement_> Program
433 %type <statement_> ProgramBody
434 %type <statement_> ProgramBodyOpt
435 %type <propertyName_> PropertyName_
436 %type <propertyName_> PropertyName
437 %type <property_> PropertyDefinition
438 %type <property_> PropertyDefinitionList_
439 %type <property_> PropertyDefinitionList
440 %type <property_> PropertyDefinitionListOpt
441 %type <expression_> RelationalExpression
442 %type <statement_> ReturnStatement
443 %type <rubyProc_> RubyProcExpression
444 %type <functionParameter_> RubyProcParameterList_
445 %type <functionParameter_> RubyProcParameterList
446 %type <functionParameter_> RubyProcParameters
447 %type <functionParameter_> RubyProcParametersOpt
448 %type <expression_> ShiftExpression
449 %type <declaration_> SingleNameBinding
450 %type <statement_> Statement__
451 %type <statement_> Statement_
452 %type <statement_> Statement
453 %type <statement_> StatementList
454 %type <statement_> StatementListOpt
455 %type <statement_> StatementListItem
456 %type <statement_> SwitchStatement
457 %type <statement_> ThrowStatement
458 %type <statement_> TryStatement
459 %type <expression_> UnaryExpression_
460 %type <expression_> UnaryExpression
461 %type <declaration_> VariableDeclaration
462 %type <declarations_> VariableDeclarationList_
463 %type <declarations_> VariableDeclarationList
464 %type <statement_> VariableStatement
465 %type <statement_> WithStatement
467 %type <word_> WordOpt
468 %type <expression_> Variable
471 %type <typedIdentifier_> ArrayedType
472 %type <expression_> BoxableExpression
473 %type <statement_> CategoryStatement
474 %type <expression_> ClassExpression
475 %type <field_> ClassFieldListOpt
476 %type <field_> ClassFields
477 %type <statement_> ClassStatement
478 %type <expression_> ClassSuperOpt
479 %type <message_> ClassMessageDeclaration
480 %type <message_> ClassMessageDeclarationListOpt
481 %type <className_> ClassName
482 %type <className_> ClassNameOpt
483 %type <protocol_> ClassProtocolListOpt
484 %type <protocol_> ClassProtocols
485 %type <protocol_> ClassProtocolsOpt
486 %type <expression_> EncodedType
487 %type <modifier_> FunctionedType
488 %type <expression_> MessageExpression
489 %type <messageParameter_> MessageParameter
490 %type <messageParameter_> MessageParameters
491 %type <messageParameter_> MessageParameterList
492 %type <messageParameter_> MessageParameterListOpt
493 %type <bool_> MessageScope
494 %type <typedIdentifier_> ModifiedType
495 %type <module_> Module
496 %type <typedIdentifier_> PrefixedType
497 %type <expression_> PrimitiveType
498 %type <argument_> SelectorCall_
499 %type <argument_> SelectorCall
500 %type <selector_> SelectorExpression_
501 %type <selector_> SelectorExpression
502 %type <selector_> SelectorExpressionOpt
503 %type <argument_> SelectorList
504 %type <word_> SelectorWordOpt
505 %type <typedIdentifier_> SuffixedType
506 %type <expression_> TypeOpt
507 %type <typedIdentifier_> TypeParenthetical
508 %type <modifier_> TypeQualifierLeft
509 %type <typedIdentifier_> TypeQualifierRight
510 %type <typedIdentifier_> TypeSignifier
511 %type <typedIdentifier_> TypedIdentifier
512 %type <typedParameter_> TypedParameterList_
513 %type <typedParameter_> TypedParameterList
514 %type <typedParameter_> TypedParameterListOpt
515 %type <argument_> VariadicCall
519 %type <propertyIdentifier_> PropertyIdentifier_
520 %type <selector_> PropertySelector_
521 %type <selector_> PropertySelector
522 %type <identifier_> QualifiedIdentifier_
523 %type <identifier_> QualifiedIdentifier
524 %type <identifier_> WildcardIdentifier
525 %type <identifier_> XMLComment
526 %type <identifier_> XMLCDATA
527 %type <identifier_> XMLElement
528 %type <identifier_> XMLElementContent
529 %type <identifier_> XMLMarkup
530 %type <identifier_> XMLPI
532 %type <attribute_> AttributeIdentifier
533 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
534 %type <expression_> PropertyIdentifier
535 %type <expression_> XMLListInitialiser
536 %type <expression_> XMLInitialiser
539 /* Token Priorities {{{ */
551 /* Lexer State {{{ */
553 : { driver.in_.push(true); }
557 : { driver.in_.push(false); }
561 : { driver.in_.pop(); }
565 : { driver.SetCondition(CYDriver::RegExpCondition); }
569 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
573 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
576 LexNoAtImplementation :
578 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
583 : LexNoBrace LexNoFunction LexNoAtImplementation
586 /* Virtual Tokens {{{ */
597 /* 7.6 Identifier Names and Identifiers {{{ */
608 : Identifier { $$ = $1; }
609 | "auto" { $$ = $1; }
610 | "break" NewLineOpt { $$ = $1; }
611 | "case" { $$ = $1; }
612 | "catch" { $$ = $1; }
613 | "class" { $$ = $1; }
614 | "const" { $$ = $1; }
615 | "continue" NewLineOpt { $$ = $1; }
616 | "debugger" { $$ = $1; }
617 | "default" { $$ = $1; }
618 | "delete" { $$ = $1; }
620 | "else" { $$ = $1; }
621 | "enum" { $$ = $1; }
622 | "export" { $$ = $1; }
623 | "extends" { $$ = $1; }
624 | "false" { $$ = $1; }
625 | "finally" { $$ = $1; }
626 /* XXX: | "for" { $$ = $1; } */
627 | "function" { $$ = $1; }
629 | "import" { $$ = $1; }
630 /* XXX: | "in" { $$ = $1; } */
632 /* XXX: | "instanceof" { $$ = $1; } */
634 // XXX: as it currently is not an Identifier
638 | "null" { $$ = $1; }
639 | "return" NewLineOpt { $$ = $1; }
640 | "super" { $$ = $1; }
641 | "switch" { $$ = $1; }
642 | "this" { $$ = $1; }
643 | "throw" NewLineOpt { $$ = $1; }
644 | "true" { $$ = $1; }
646 | "typeof" { $$ = $1; }
648 | "void" { $$ = $1; }
649 | "while" { $$ = $1; }
650 | "with" { $$ = $1; }
659 : Identifier_ { $$ = $1; }
662 | "typedef" { $$ = $1; }
667 | "implements" { $$ = $1; }
668 | "interface" { $$ = $1; }
669 | "package" { $$ = $1; }
670 | "private" { $$ = $1; }
671 | "protected" { $$ = $1; }
672 | "public" { $$ = $1; }
673 | "static" { $$ = $1; }
675 | "abstract" { $$ = $1; }
676 | "boolean" { $$ = $1; }
677 | "byte" { $$ = $1; }
678 | "char" { $$ = $1; }
679 | "double" { $$ = $1; }
680 | "final" { $$ = $1; }
681 | "float" { $$ = $1; }
682 | "goto" { $$ = $1; }
684 | "long" { $$ = $1; }
685 | "native" { $$ = $1; }
686 | "short" { $$ = $1; }
687 | "synchronized" { $$ = $1; }
688 | "throws" { $$ = $1; }
689 | "transient" { $$ = $1; }
690 | "volatile" { $$ = $1; }
692 // XXX: currently I only have this as Word
693 // | "let" { $$ = $1; }
695 | "yield" { $$ = $1; }
697 | "each" { $$ = $1; }
702 : Identifier { $$ = $1; }
707 /* 7.8 Literals {{{ */
709 : NullLiteral { $$ = $1; }
710 | ValueLiteral { $$ = $1; }
714 : BooleanLiteral { $$ = $1; }
715 | NumericLiteral { $$ = $1; }
716 | StringLiteral { $$ = $1; }
717 | RegularExpressionLiteral { $$ = $1; }
720 /* 7.8.1 Null Literals {{{ */
722 : "null" { $$ = $1; }
725 /* 7.8.2 Boolean Literals {{{ */
727 : "true" { $$ = $1; }
728 | "false" { $$ = $1; }
732 /* 7.9 Automatic Semicolon Insertion {{{ */
734 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
739 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
744 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
748 /* 11.1 Primary Expressions {{{ */
750 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
754 : Parenthetical { $$ = $1; }
759 : Identifier { $$ = CYNew CYVariable($1); }
763 : "this" { $$ = $1; }
764 | Variable { $$ = $1; }
765 | Literal { $$ = $1; }
766 | ArrayInitialiser { $$ = $1; }
767 | ObjectLiteral { $$ = $1; }
768 | Parenthetical { $$ = $1; }
769 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
772 /* 11.1.4 Array Initializer {{{ */
774 : ArrayLiteral { $$ = $1; }
775 | ArrayComprehension { $$ = $1; }
778 /* 11.1.4.1 Array Literal {{{ */
780 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
784 : AssignmentExpression { $$ = $1; }
788 : Element { $$ = $1; }
789 | LexSetRegExp { $$ = NULL; }
793 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
794 | Element { $$ = CYNew CYElement($1, NULL); }
798 : ElementList { $$ = $1; }
799 | LexSetRegExp { $$ = NULL; }
802 /* 11.1.4.2 Array Comprehension {{{ */
804 : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
808 : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
813 | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
814 | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
818 : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
822 : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
825 /* 11.1.5 Object Initialiser {{{ */
827 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
830 PropertyDefinitionList_
831 : "," PropertyDefinitionList { $$ = $2; }
832 | "," LexSetRegExp { $$ = NULL; }
836 PropertyDefinitionList
837 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
840 PropertyDefinitionListOpt
841 : PropertyDefinitionList { $$ = $1; }
842 | LexSetRegExp { $$ = NULL; }
846 // XXX: this should be IdentifierName
847 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
848 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
853 : IdentifierName { $$ = $1; }
854 | StringLiteral { $$ = $1; }
855 | NumericLiteral { $$ = $1; }
859 : LexSetRegExp PropertyName_ { $$ = $2; }
863 /* 11.2 Left-Hand-Side Expressions {{{ */
865 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
866 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
867 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
871 : MemberExpression { $$ = $1; }
872 //| "super" { $$ = $1; }
876 : LexSetRegExp PrimaryExpression { $$ = $2; }
877 | LexSetRegExp FunctionExpression { $$ = $2; }
878 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
879 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
883 : MemberExpression { $$ = $1; }
884 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
893 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
894 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
898 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
902 : "," ArgumentList { $$ = $2; }
907 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
911 : ArgumentList { $$ = $1; }
912 | LexSetRegExp { $$ = NULL; }
915 LeftHandSideExpression
916 : NewExpression { $$ = $1; }
917 | CallExpression { $$ = $1; }
920 /* 11.3 Postfix Expressions {{{ */
922 : %prec "" LeftHandSideExpression { $$ = $1; }
923 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
924 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
927 /* 11.4 Unary Operators {{{ */
929 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
930 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
931 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
932 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
933 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
934 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
935 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
936 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
937 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
938 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
939 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
943 : PostfixExpression { $$ = $1; }
944 | LexSetRegExp UnaryExpression_ { $$ = $2; }
947 /* 11.5 Multiplicative Operators {{{ */
948 MultiplicativeExpression
949 : UnaryExpression { $$ = $1; }
950 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
951 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
952 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
955 /* 11.6 Additive Operators {{{ */
957 : MultiplicativeExpression { $$ = $1; }
958 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
959 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
962 /* 11.7 Bitwise Shift Operators {{{ */
964 : AdditiveExpression { $$ = $1; }
965 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
966 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
967 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
970 /* 11.8 Relational Operators {{{ */
972 : ShiftExpression { $$ = $1; }
973 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
974 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
975 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
976 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
977 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
978 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
981 /* 11.9 Equality Operators {{{ */
983 : RelationalExpression { $$ = $1; }
984 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
985 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
986 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
987 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
990 /* 11.10 Binary Bitwise Operators {{{ */
992 : EqualityExpression { $$ = $1; }
993 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
997 : BitwiseANDExpression { $$ = $1; }
998 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
1002 : BitwiseXORExpression { $$ = $1; }
1003 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
1006 /* 11.11 Binary Logical Operators {{{ */
1007 LogicalANDExpression
1008 : BitwiseORExpression { $$ = $1; }
1009 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
1013 : LogicalANDExpression { $$ = $1; }
1014 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
1017 /* 11.12 Conditional Operator ( ? : ) {{{ */
1018 ConditionalExpression
1019 : LogicalORExpression { $$ = $1; }
1020 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1023 /* 11.13 Assignment Operators {{{ */
1024 AssignmentExpression
1025 : ConditionalExpression { $$ = $1; }
1026 | ArrowFunction { $$ = $1; }
1027 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1028 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1029 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1030 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1031 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1032 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1033 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1034 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1035 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1036 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1037 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1038 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1041 /* 11.14 Comma Operator {{{ */
1043 : "," Expression { $$ = $2; }
1044 | { $$ = CYNew CYCompound(); }
1048 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1052 : Expression { $$ = $1; }
1053 | LexSetRegExp { $$ = NULL; }
1057 /* 12 Statements {{{ */
1059 : Block { $$ = $1; }
1060 | VariableStatement { $$ = $1; }
1061 | EmptyStatement { $$ = $1; }
1062 | IfStatement { $$ = $1; }
1063 | BreakableStatement { $$ = $1; }
1064 | ContinueStatement { $$ = $1; }
1065 | BreakStatement { $$ = $1; }
1066 | ReturnStatement { $$ = $1; }
1067 | WithStatement { $$ = $1; }
1068 | LabelledStatement { $$ = $1; }
1069 | ThrowStatement { $$ = $1; }
1070 | TryStatement { $$ = $1; }
1071 | DebuggerStatement { $$ = $1; }
1075 : LexSetRegExp Statement__ { $$ = $2; }
1076 | ExpressionStatement { $$ = $1; }
1080 : LexSetStatement Statement_ { $$ = $2; }
1084 : FunctionDeclaration { $$ = $1; }
1085 | LexicalDeclaration { $$ = $1; }
1089 : LexSetRegExp Declaration__ { $$ = $2; }
1093 : LexSetStatement Declaration_ { $$ = $2; }
1097 : IterationStatement { $$ = $1; }
1098 | SwitchStatement { $$ = $1; }
1101 /* 12.1 Block {{{ */
1103 : BRACE StatementListOpt "}" { $$ = $2; }
1107 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1111 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1115 : StatementList { $$ = $1; }
1116 | LexSetStatement LexSetRegExp { $$ = NULL; }
1120 : Statement { $$ = $1; }
1121 | Declaration { $$ = $1; }
1125 /* 12.2 Declarations {{{ */
1127 : Identifier { $$ = $1; }
1134 // XXX: BindingPattern
1136 /* 12.2.1 Let and Const Declarations {{{ */
1138 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1146 /* 12.2.2 Variable Statement {{{ */
1148 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1151 VariableDeclarationList_
1152 : "," VariableDeclarationList { $$ = $2; }
1156 VariableDeclarationList
1157 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1161 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1162 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1166 : "=" AssignmentExpression { $$ = $2; }
1170 : Initialiser { $$ = $1; }
1174 /* 12.2.4 Destructuring Binding Patterns {{{ */
1178 : SingleNameBinding { $$ = $1; }
1182 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1186 /* 12.3 Empty Statement {{{ */
1188 : ";" { $$ = CYNew CYEmpty(); }
1191 /* 12.4 Expression Statement {{{ */
1193 : Expression Terminator { $$ = CYNew CYExpress($1); }
1196 /* 12.5 The if Statement {{{ */
1198 : "else" Statement { $$ = $2; }
1199 | %prec "if" { $$ = NULL; }
1203 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1207 /* 12.6.1 The do-while Statement {{{ */
1209 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1212 /* 12.6.2 The while Statement {{{ */
1214 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1217 /* 12.6.3 The for Statement {{{ */
1219 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1222 ForStatementInitialiser
1223 : ExpressionOpt { $$ = $1; }
1224 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1227 /* 12.6.4 The for-in and for-of Statements {{{ */
1229 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1230 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1233 ForInStatementInitialiser
1234 : LeftHandSideExpression { $$ = $1; }
1235 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1239 /* 12.7 The continue Statement {{{ */
1241 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1242 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1245 /* 12.8 The break Statement {{{ */
1247 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1248 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1251 /* 12.9 The return Statement {{{ */
1253 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1254 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1257 /* 12.10 The with Statement {{{ */
1259 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1263 /* 12.11 The switch Statement {{{ */
1265 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1269 : BRACE CaseClausesOpt "}" { $$ = $2; }
1273 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1277 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1278 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1283 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1286 /* 12.12 Labelled Statements {{{ */
1288 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1291 /* 12.13 The throw Statement {{{ */
1293 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1294 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1297 /* 12.14 The try Statement {{{ */
1299 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1303 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1308 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1312 /* 12.14 The debugger Statement {{{ */
1314 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1318 /* 13.1 Function Definitions {{{ */
1320 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1324 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1327 FormalParameterList_
1328 : "," FormalParameterList { $$ = $2; }
1333 // XXX: : FunctionRestParameter { $$ = $1; }
1334 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1337 FormalParameterListOpt
1338 : FormalParameterList
1342 /* XXX: FunctionRestParameter
1343 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1347 : BindingElement { $$ = $1; }
1351 : StatementListOpt { $$ = $1; }
1354 /* 13.2 Arrow Function Definitions {{{ */
1356 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1360 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1361 //| ParentheticalOpt { $$ = $1; }
1365 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1366 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1369 /* 14 Program {{{ */
1371 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1375 : StatementList { $$ = $1; }
1379 : ProgramBody { $$ = $1; }
1380 | LexSetStatement LexSetRegExp { $$ = NULL; }
1385 /* Cycript (Objective-C): Type Encoding {{{ */
1387 : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
1391 : Identifier { $$ = CYNew CYTypedIdentifier($1); }
1392 | TypeParenthetical { $$ = $1; }
1396 : ArrayedType "[" NumericLiteral "]" { $$ = $1; $$->modifier_ = CYNew CYTypeArrayOf($3, $$->modifier_); }
1397 | TypeSignifier { $$ = $1; }
1398 | { $$ = CYNew CYTypedIdentifier(); }
1402 : "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = CYNew CYTypeFunctionWith($3); }
1406 : ArrayedType { $$ = $1; }
1407 | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
1408 | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
1409 | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1413 : "*" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1417 : "const" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeConstant(); }
1418 /* XXX: | "volatile" TypeQualifierLeft { $$ = $2; CYSetLast($$) = CYNew CYTypeVolatile(); } */
1423 : "const" TypeQualifierRight { $$ = $2; $$->modifier_ = CYNew CYTypeConstant($$->modifier_); }
1424 | PrefixedType { $$ = $1; }
1425 | SuffixedType { $$ = $1; }
1429 : Variable { $$ = $1; }
1430 | "void" { $$ = CYNew cy::Syntax::New(CYNew CYVariable(CYNew CYIdentifier("Type")), CYNew CYArgument(CYNew CYString("v"))); }
1434 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->type_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
1438 : TypedIdentifier { $$ = CYNew CYEncodedType($1); }
1442 : AtEncode "(" EncodedType ")" { $$ = $3; }
1445 /* Cycript (Objective-C): @class Declaration {{{ */
1447 /* XXX: why the hell did I choose MemberExpression? */
1448 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1453 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1454 | LexSetRegExp { $$ = NULL; }
1458 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1462 : "+" { $$ = false; }
1463 | "-" { $$ = true; }
1467 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1472 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1475 MessageParameterList
1476 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1479 MessageParameterListOpt
1480 : MessageParameterList { $$ = $1; }
1485 : MessageParameterList { $$ = $1; }
1486 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1489 ClassMessageDeclaration
1490 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1493 ClassMessageDeclarationListOpt
1494 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1495 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1500 : Identifier { $$ = $1; }
1501 | "(" AssignmentExpression ")" { $$ = $2; }
1505 : ClassName { $$ = $1; }
1509 // XXX: this should be AssignmentExpressionNoRight
1511 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1515 : "," ClassProtocols { $$ = $2; }
1519 ClassProtocolListOpt
1520 : "<" ClassProtocols ">" { $$ = $2; }
1525 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1529 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1537 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1541 : ClassExpression { $$ = $1; }
1545 : ClassStatement { $$ = $1; }
1546 | CategoryStatement { $$ = $1; }
1549 /* Cycript (Objective-C): Send Message {{{ */
1551 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1556 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1557 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1561 : SelectorCall { $$ = $1; }
1562 | VariadicCall { $$ = $1; }
1566 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1570 : SelectorCall { $$ = $1; }
1571 | Word { $$ = CYNew CYArgument($1, NULL); }
1575 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1576 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1580 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1584 : SelectorExpression_ { $$ = $1; }
1585 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1588 SelectorExpressionOpt
1589 : SelectorExpression_ { $$ = $1; }
1594 : MessageExpression { $$ = $1; }
1595 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1598 /* Cycript (Objective-C): @import Directive {{{ */
1600 : Module "." Word { $$ = CYNew CYModule($3, $1); }
1601 | Word { $$ = CYNew CYModule($1); }
1605 : "@import" Module { $$ = CYNew CYImport($2); }
1608 /* Cycript (Objective-C): Boxed Expressions {{{ */
1610 : NullLiteral { $$ = $1; }
1611 | BooleanLiteral { $$ = $1; }
1612 | NumericLiteral { $$ = $1; }
1613 | StringLiteral { $$ = $1; }
1614 | ArrayLiteral { $$ = $1; }
1615 | ObjectLiteral { $$ = $1; }
1616 | Parenthetical { $$ = $1; }
1617 | "YES" { $$ = CYNew CYTrue(); }
1618 | "NO" { $$ = CYNew CYFalse(); }
1622 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1625 /* Cycript (Objective-C): Block Expressions {{{ */
1627 : TypeQualifierLeft PrimitiveType { $$ = CYNew CYTypedIdentifier(); $$->type_ = $2; $$->modifier_ = $1; }
1628 | ModifiedType "*" { $$ = $1; $$->modifier_ = CYNew CYTypePointerTo($$->modifier_); }
1632 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1638 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1639 LeftHandSideExpression
1640 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1644 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1648 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1649 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1650 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1653 /* Cycript (C): auto Compatibility {{{ */
1658 /* Cycript (C): Lambda Expressions {{{ */
1660 : "," TypedParameterList { $$ = $2; }
1665 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1668 TypedParameterListOpt
1669 : TypedParameterList { $$ = $1; }
1674 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14, $10, $17); }
1677 /* Cycript (C): Type Definitions {{{ */
1679 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1684 /* YUI: Documentation Comments {{{ */
1686 : Comment { $$ = $1; }
1691 /* Lexer State {{{ */
1693 : { driver.PushCondition(CYDriver::RegExpCondition); }
1697 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1701 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1705 : { driver.PopCondition(); }
1709 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1713 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1716 /* Virtual Tokens {{{ */
1723 /* 8.1 Context Keywords {{{ */
1725 : "namespace" { $$ = $1; }
1726 | "xml" { $$ = $1; }
1729 /* 8.3 XML Initialiser Input Elements {{{ */
1731 : XMLComment { $$ = $1; }
1732 | XMLCDATA { $$ = $1; }
1733 | XMLPI { $$ = $1; }
1737 /* 11.1 Primary Expressions {{{ */
1739 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1740 | XMLInitialiser { $$ = $1; }
1741 | XMLListInitialiser { $$ = $1; }
1745 : AttributeIdentifier { $$ = $1; }
1746 | QualifiedIdentifier { $$ = $1; }
1747 | WildcardIdentifier { $$ = $1; }
1750 /* 11.1.1 Attribute Identifiers {{{ */
1752 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1756 : PropertySelector { $$ = $1; }
1757 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1761 : Identifier { $$ = CYNew CYSelector($1); }
1762 | WildcardIdentifier { $$ = $1; }
1765 /* 11.1.2 Qualified Identifiers {{{ */
1766 QualifiedIdentifier_
1767 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1768 | QualifiedIdentifier { $$ = $1; }
1772 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1775 /* 11.1.3 Wildcard Identifiers {{{ */
1777 : "*" { $$ = CYNew CYWildcard(); }
1780 /* 11.1.4 XML Initialiser {{{ */
1782 : XMLMarkup { $$ = $1; }
1783 | XMLElement { $$ = $1; }
1787 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1788 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1792 : LexPushXMLTag XMLTagName XMLAttributes
1796 : BRACE LexPushRegExp Expression LexPop "}"
1805 : XMLAttributes_ XMLAttribute
1810 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1811 | XMLAttributes_ XMLWhitespaceOpt
1820 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1824 : XMLExpression XMLElementContentOpt
1825 | XMLMarkup XMLElementContentOpt
1826 | XMLText XMLElementContentOpt
1827 | XMLElement XMLElementContentOpt
1830 XMLElementContentOpt
1835 /* 11.1.5 XMLList Initialiser {{{ */
1837 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1841 /* 11.2 Left-Hand-Side Expressions {{{ */
1843 : Identifier { $$ = $1; }
1844 | PropertyIdentifier { $$ = $1; }
1848 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1849 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1850 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1853 /* 12.1 The default xml namespace Statement {{{ */
1854 /* XXX: DefaultXMLNamespaceStatement
1855 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1859 : DefaultXMLNamespaceStatement { $$ = $1; }
1864 /* JavaScript 1.7: Array Comprehensions {{{ */
1866 : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
1870 : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1871 | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1874 /* JavaScript 1.7: for each {{{ */
1876 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1879 /* JavaScript 1.7: let Statements {{{ */
1881 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1889 /* JavaScript FTW: Ruby Blocks {{{ */
1890 RubyProcParameterList_
1891 : "," RubyProcParameterList { $$ = $2; }
1895 RubyProcParameterList
1896 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1901 : "|" RubyProcParameterList "|" { $$ = $2; }
1902 | "||" { $$ = NULL; }
1905 RubyProcParametersOpt
1906 : RubyProcParameters
1911 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1915 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1919 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }