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_;
78 CYProperty *property_;
79 CYPropertyName *propertyName_;
80 CYRubyProc *rubyProc_;
81 CYStatement *statement_;
88 CYClassName *className_;
91 CYMessageParameter *messageParameter_;
92 CYProtocol *protocol_;
93 CYSelectorPart *selector_;
94 CYTypeModifier *type_;
95 CYTypedIdentifier *typedIdentifier_;
96 CYTypedParameter *typedParameter_;
100 CYAttribute *attribute_;
101 CYPropertyIdentifier *propertyIdentifier_;
102 CYSelector *selector_;
107 #define YYSTYPE YYSTYPE
110 @if Bison24 %code provides {
111 int cylex(YYSTYPE *, cy::location *, void *);
118 @if Bison23 %skeleton "lalr1.cc"
119 @if Bison24 %language "C++"
122 @$.begin.filename = @$.end.filename = &driver.filename_;
133 %parse-param { CYDriver &driver }
134 %lex-param { void *cyscanner }
136 /* Token Declarations {{{ */
142 %token XMLAttributeValue
144 %token XMLTagCharacters
150 %token LeftRight "<>"
151 %token LeftSlashRight "</>"
153 %token SlashRight "/>"
154 %token LeftSlash "</"
156 %token ColonColon "::"
157 %token PeriodPeriod ".."
160 @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"
238 %token AtImplementation "@implementation"
239 %token AtImplementation_ ";@implementation"
240 %token AtImport "@import"
241 %token AtEncode "@encode"
243 %token AtSelector "@selector"
246 %token <false_> False "false"
247 %token <null_> Null "null"
248 %token <true_> True "true"
250 // ES3/ES5/WIE/JSC Reserved
251 %token <word_> Auto "auto"
252 %token <word_> Break "break"
253 %token <word_> Case "case"
254 %token <word_> Catch "catch"
255 %token <word_> Continue "continue"
256 %token <word_> Default "default"
257 %token <word_> Delete "delete"
258 %token <word_> Do "do"
259 %token <word_> Else "else"
260 %token <word_> Finally "finally"
261 %token <word_> For "for"
262 %token <word_> Function "function"
263 %token <word_> Function_ ";function"
264 %token <word_> If "if"
265 %token <word_> In "in"
266 %token <word_> In_ "!in"
267 %token <word_> InstanceOf "instanceof"
268 %token <word_> New "new"
269 %token <word_> Return "return"
270 %token <word_> Switch "switch"
271 %token <this_> This "this"
272 %token <word_> Throw "throw"
273 %token <word_> Try "try"
274 %token <word_> TypeOf "typeof"
275 %token <word_> Var "var"
276 %token <word_> Void "void"
277 %token <word_> While "while"
278 %token <word_> With "with"
280 // ES3/IE6 Future, ES5/JSC Reserved
281 %token <word_> Debugger "debugger"
283 // ES3/ES5/IE6 Future, JSC Reserved
284 %token <word_> Const "const"
286 // ES3/ES5/IE6/JSC Future
287 %token <word_> Class "class"
288 %token <word_> Enum "enum"
289 %token <word_> Export "export"
290 %token <word_> Extends "extends"
291 %token <word_> Import "import"
292 %token <word_> Super "super"
294 // ES3 Future, ES5 Strict Future
295 %token <identifier_> Implements "implements"
296 %token <identifier_> Interface "interface"
297 %token <identifier_> Package "package"
298 %token <identifier_> Private "private"
299 %token <identifier_> Protected "protected"
300 %token <identifier_> Public "public"
301 %token <identifier_> Static "static"
304 %token <identifier_> Abstract "abstract"
305 %token <identifier_> Boolean "boolean"
306 %token <identifier_> Byte "byte"
307 %token <identifier_> Char "char"
308 %token <identifier_> Double "double"
309 %token <identifier_> Final "final"
310 %token <identifier_> Float "float"
311 %token <identifier_> Goto "goto"
312 %token <identifier_> Int "int"
313 %token <identifier_> Long "long"
314 %token <identifier_> Native "native"
315 %token <identifier_> Short "short"
316 %token <identifier_> Synchronized "synchronized"
317 %token <identifier_> Throws "throws"
318 %token <identifier_> Transient "transient"
319 %token <identifier_> Volatile "volatile"
322 %token <identifier_> Let "let"
323 %token <identifier_> Yield "yield"
326 %token <identifier_> Each "each"
327 %token <identifier_> Of "of"
331 %token <identifier_> Namespace "namespace"
332 %token <identifier_> XML "xml"
337 %token <identifier_> Identifier_
338 %token <number_> NumericLiteral
339 %token <string_> StringLiteral
340 %token <literal_> RegularExpressionLiteral
342 %type <expression_> AdditiveExpression
343 %type <argument_> ArgumentList_
344 %type <argument_> ArgumentList
345 %type <argument_> ArgumentListOpt
346 %type <argument_> Arguments
347 %type <literal_> ArrayLiteral
348 %type <expression_> ArrowFunction
349 %type <functionParameter_> ArrowParameters
350 %type <expression_> AssignmentExpression
351 %type <identifier_> Binding
352 %type <identifier_> BindingIdentifier
353 %type <expression_> BitwiseANDExpression
354 %type <statement_> Block_
355 %type <statement_> Block
356 %type <boolean_> BooleanLiteral
357 %type <declaration_> BindingElement
358 %type <expression_> BitwiseORExpression
359 %type <expression_> BitwiseXORExpression
360 %type <statement_> BreakStatement
361 %type <statement_> BreakableStatement
362 %type <expression_> CallExpression_
363 %type <expression_> CallExpression
364 %type <clause_> CaseBlock
365 %type <clause_> CaseClause
366 %type <clause_> CaseClausesOpt
367 %type <catch_> CatchOpt
368 %type <comprehension_> ComprehensionForList
369 %type <comprehension_> ComprehensionForListOpt
370 %type <comprehension_> ComprehensionList
371 %type <comprehension_> ComprehensionListOpt
372 %type <expression_> ConditionalExpression
373 %type <statement_> ContinueStatement
374 %type <statement_> ConciseBody
375 %type <statement_> DebuggerStatement
376 %type <statement_> Declaration__
377 %type <statement_> Declaration_
378 %type <statement_> Declaration
379 %type <clause_> DefaultClause
380 %type <expression_> Element
381 %type <expression_> ElementOpt
382 %type <element_> ElementList
383 %type <element_> ElementListOpt
384 %type <statement_> ElseStatementOpt
385 %type <statement_> EmptyStatement
386 %type <expression_> EqualityExpression
387 %type <compound_> Expression_
388 %type <compound_> Expression
389 %type <expression_> ExpressionOpt
390 %type <statement_> ExpressionStatement
391 %type <finally_> FinallyOpt
392 %type <comprehension_> ForComprehension
393 %type <for_> ForStatementInitialiser
394 %type <forin_> ForInStatementInitialiser
395 %type <declaration_> FormalParameter
396 %type <functionParameter_> FormalParameterList_
397 %type <functionParameter_> FormalParameterList
398 %type <functionParameter_> FormalParameterListOpt
399 %type <statement_> FunctionBody
400 %type <statement_> FunctionDeclaration
401 %type <expression_> FunctionExpression
402 %type <identifier_> Identifier
403 %type <identifier_> IdentifierOpt
404 %type <word_> IdentifierName
405 %type <comprehension_> IfComprehension
406 %type <statement_> IfStatement
407 %type <expression_> Initialiser
408 %type <expression_> InitialiserOpt
409 %type <statement_> IterationStatement
410 %type <statement_> LabelledStatement
411 %type <expression_> LeftHandSideExpression
412 %type <statement_> LetStatement
413 %type <statement_> LexicalDeclaration
414 %type <literal_> Literal
415 %type <literal_> ValueLiteral
416 %type <expression_> LogicalANDExpression
417 %type <expression_> LogicalORExpression
418 %type <member_> MemberAccess
419 %type <expression_> MemberExpression_
420 %type <expression_> MemberExpression
421 %type <expression_> MultiplicativeExpression
422 %type <expression_> NewExpression
423 %type <null_> NullLiteral
424 %type <literal_> ObjectLiteral
425 %type <compound_> Parenthetical
426 %type <compound_> ParentheticalOpt
427 %type <expression_> PostfixExpression
428 %type <expression_> PrimaryExpression
429 %type <statement_> Program
430 %type <statement_> ProgramBody
431 %type <statement_> ProgramBodyOpt
432 %type <propertyName_> PropertyName_
433 %type <propertyName_> PropertyName
434 %type <property_> PropertyDefinition
435 %type <property_> PropertyDefinitionList_
436 %type <property_> PropertyDefinitionList
437 %type <property_> PropertyDefinitionListOpt
438 %type <expression_> RelationalExpression
439 %type <statement_> ReturnStatement
440 %type <rubyProc_> RubyProcExpression
441 %type <functionParameter_> RubyProcParameterList_
442 %type <functionParameter_> RubyProcParameterList
443 %type <functionParameter_> RubyProcParameters
444 %type <functionParameter_> RubyProcParametersOpt
445 %type <expression_> ShiftExpression
446 %type <declaration_> SingleNameBinding
447 %type <statement_> Statement__
448 %type <statement_> Statement_
449 %type <statement_> Statement
450 %type <statement_> StatementList
451 %type <statement_> StatementListOpt
452 %type <statement_> StatementListItem
453 %type <statement_> SwitchStatement
454 %type <statement_> ThrowStatement
455 %type <statement_> TryStatement
456 %type <expression_> UnaryExpression_
457 %type <expression_> UnaryExpression
458 %type <declaration_> VariableDeclaration
459 %type <declarations_> VariableDeclarationList_
460 %type <declarations_> VariableDeclarationList
461 %type <statement_> VariableStatement
462 %type <statement_> WithStatement
464 %type <word_> WordOpt
465 %type <expression_> Variable
468 %type <typedIdentifier_> ArrayedType
469 %type <expression_> BoxableExpression
470 %type <statement_> CategoryStatement
471 %type <expression_> ClassExpression
472 %type <field_> ClassFieldListOpt
473 %type <field_> ClassFields
474 %type <statement_> ClassStatement
475 %type <expression_> ClassSuperOpt
476 %type <message_> ClassMessageDeclaration
477 %type <message_> ClassMessageDeclarationListOpt
478 %type <className_> ClassName
479 %type <className_> ClassNameOpt
480 %type <protocol_> ClassProtocolListOpt
481 %type <protocol_> ClassProtocols
482 %type <protocol_> ClassProtocolsOpt
483 %type <type_> ConcreteType
484 %type <expression_> EncodedType
485 %type <expression_> MessageExpression
486 %type <messageParameter_> MessageParameter
487 %type <messageParameter_> MessageParameters
488 %type <messageParameter_> MessageParameterList
489 %type <messageParameter_> MessageParameterListOpt
490 %type <bool_> MessageScope
491 %type <type_> ModifiedType_
492 %type <type_> ModifiedType
493 %type <typedIdentifier_> PrefixedType
494 %type <expression_> PrimitiveType
495 %type <argument_> SelectorCall_
496 %type <argument_> SelectorCall
497 %type <selector_> SelectorExpression_
498 %type <selector_> SelectorExpression
499 %type <selector_> SelectorExpressionOpt
500 %type <argument_> SelectorList
501 %type <word_> SelectorWordOpt
502 %type <typedIdentifier_> SuffixedType
503 %type <expression_> TypeOpt
504 %type <typedIdentifier_> TypeParenthetical
505 %type <type_> TypeQualifierLeft
506 %type <type_> TypeQualifierRight
507 %type <typedIdentifier_> TypeSignifier
508 %type <typedIdentifier_> TypedIdentifier
509 %type <typedParameter_> TypedParameterList_
510 %type <typedParameter_> TypedParameterList
511 %type <typedParameter_> TypedParameterListOpt
512 %type <argument_> VariadicCall
516 %type <propertyIdentifier_> PropertyIdentifier_
517 %type <selector_> PropertySelector_
518 %type <selector_> PropertySelector
519 %type <identifier_> QualifiedIdentifier_
520 %type <identifier_> QualifiedIdentifier
521 %type <identifier_> WildcardIdentifier
522 %type <identifier_> XMLComment
523 %type <identifier_> XMLCDATA
524 %type <identifier_> XMLElement
525 %type <identifier_> XMLElementContent
526 %type <identifier_> XMLMarkup
527 %type <identifier_> XMLPI
529 %type <attribute_> AttributeIdentifier
530 /* XXX: %type <statement_> DefaultXMLNamespaceStatement */
531 %type <expression_> PropertyIdentifier
532 %type <expression_> XMLListInitialiser
533 %type <expression_> XMLInitialiser
536 /* Token Priorities {{{ */
548 /* Lexer State {{{ */
550 : { driver.in_.push(true); }
554 : { driver.in_.push(false); }
558 : { driver.in_.pop(); }
562 : { driver.SetCondition(CYDriver::RegExpCondition); }
566 : { if (yychar == yyempty_) driver.no_.OpenBrace = true; else if (yychar == token::OpenBrace || yychar == token::OpenBrace_) yychar = token::OpenBrace__; }
570 : { if (yychar == yyempty_) driver.no_.Function = true; else if (yychar == token::Function) yychar = token::Function_; }
573 LexNoAtImplementation :
575 { if (yychar == yyempty_) driver.no_.AtImplementation = true; else if (yychar == token::AtImplementation) yychar = token::AtImplementation_; }
580 : LexNoBrace LexNoFunction LexNoAtImplementation
583 /* Virtual Tokens {{{ */
594 /* 7.6 Identifier Names and Identifiers {{{ */
605 : Identifier { $$ = $1; }
606 | "auto" { $$ = $1; }
607 | "break" NewLineOpt { $$ = $1; }
608 | "case" { $$ = $1; }
609 | "catch" { $$ = $1; }
610 | "class" { $$ = $1; }
611 | "const" { $$ = $1; }
612 | "continue" NewLineOpt { $$ = $1; }
613 | "debugger" { $$ = $1; }
614 | "default" { $$ = $1; }
615 | "delete" { $$ = $1; }
617 | "else" { $$ = $1; }
618 | "enum" { $$ = $1; }
619 | "export" { $$ = $1; }
620 | "extends" { $$ = $1; }
621 | "false" { $$ = $1; }
622 | "finally" { $$ = $1; }
623 /* XXX: | "for" { $$ = $1; } */
624 | "function" { $$ = $1; }
626 | "import" { $$ = $1; }
627 /* XXX: | "in" { $$ = $1; } */
629 /* XXX: | "instanceof" { $$ = $1; } */
631 // XXX: as it currently is not an Identifier
635 | "null" { $$ = $1; }
636 | "return" NewLineOpt { $$ = $1; }
637 | "super" { $$ = $1; }
638 | "switch" { $$ = $1; }
639 | "this" { $$ = $1; }
640 | "throw" NewLineOpt { $$ = $1; }
641 | "true" { $$ = $1; }
643 | "typeof" { $$ = $1; }
645 | "void" { $$ = $1; }
646 | "while" { $$ = $1; }
647 | "with" { $$ = $1; }
656 : Identifier_ { $$ = $1; }
659 | "typedef" { $$ = $1; }
662 | "implements" { $$ = $1; }
663 | "interface" { $$ = $1; }
664 | "package" { $$ = $1; }
665 | "private" { $$ = $1; }
666 | "protected" { $$ = $1; }
667 | "public" { $$ = $1; }
668 | "static" { $$ = $1; }
670 | "abstract" { $$ = $1; }
671 | "boolean" { $$ = $1; }
672 | "byte" { $$ = $1; }
673 | "char" { $$ = $1; }
674 | "double" { $$ = $1; }
675 | "final" { $$ = $1; }
676 | "float" { $$ = $1; }
677 | "goto" { $$ = $1; }
679 | "long" { $$ = $1; }
680 | "native" { $$ = $1; }
681 | "short" { $$ = $1; }
682 | "synchronized" { $$ = $1; }
683 | "throws" { $$ = $1; }
684 | "transient" { $$ = $1; }
685 | "volatile" { $$ = $1; }
687 // XXX: currently I only have this as Word
688 // | "let" { $$ = $1; }
690 | "yield" { $$ = $1; }
692 | "each" { $$ = $1; }
697 : Identifier { $$ = $1; }
702 /* 7.8 Literals {{{ */
704 : NullLiteral { $$ = $1; }
705 | ValueLiteral { $$ = $1; }
709 : BooleanLiteral { $$ = $1; }
710 | NumericLiteral { $$ = $1; }
711 | StringLiteral { $$ = $1; }
712 | RegularExpressionLiteral { $$ = $1; }
715 /* 7.8.1 Null Literals {{{ */
717 : "null" { $$ = $1; }
720 /* 7.8.2 Boolean Literals {{{ */
722 : "true" { $$ = $1; }
723 | "false" { $$ = $1; }
727 /* 7.9 Automatic Semicolon Insertion {{{ */
729 : { driver.Warning(yylloc, "warning, automatic semi-colon insertion required"); }
734 | error { if (yychar != yyeof_ && yychar != token::CloseBrace && !yylval.newline_) YYABORT; else { yyerrok; driver.errors_.pop_back(); } } StrictSemi
739 | error { yyerrok; driver.errors_.pop_back(); } StrictSemi
743 /* 11.1 Primary Expressions {{{ */
745 : "(" LexPushInOff Expression ")" LexPopIn { $$ = $3; }
749 : Parenthetical { $$ = $1; }
754 : Identifier { $$ = CYNew CYVariable($1); }
758 : "this" { $$ = $1; }
759 | Variable { $$ = $1; }
760 | Literal { $$ = $1; }
761 | ArrayLiteral { $$ = $1; }
762 | ObjectLiteral { $$ = $1; }
763 | Parenthetical { $$ = $1; }
764 | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
767 /* 11.1.4.1 Array Initialiser {{{ */
769 : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
773 : AssignmentExpression { $$ = $1; }
777 : Element { $$ = $1; }
778 | LexSetRegExp { $$ = NULL; }
782 : ElementOpt "," ElementListOpt { $$ = CYNew CYElement($1, $3); }
783 | Element { $$ = CYNew CYElement($1, NULL); }
787 : ElementList { $$ = $1; }
788 | LexSetRegExp { $$ = NULL; }
791 /* 11.1.4.2 Array Comprehension {{{ */
793 : "[" LexPushInOff AssignmentExpression ComprehensionForList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
797 : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
798 | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
801 ComprehensionForListOpt
802 : ComprehensionForList { $$ = $1; }
803 | "if" Expression { $$ = CYNew CYIfComprehension($2); }
807 /* 11.1.5 Object Initialiser {{{ */
809 : BRACE LexPushInOff PropertyDefinitionListOpt "}" LexPopIn { $$ = CYNew CYObject($3); }
812 PropertyDefinitionList_
813 : "," PropertyDefinitionList { $$ = $2; }
814 | "," LexSetRegExp { $$ = NULL; }
818 PropertyDefinitionList
819 : PropertyDefinition PropertyDefinitionList_ { $1->SetNext($2); $$ = $1; }
822 PropertyDefinitionListOpt
823 : PropertyDefinitionList { $$ = $1; }
824 | LexSetRegExp { $$ = NULL; }
828 // XXX: this should be IdentifierName
829 : LexSetRegExp Identifier { $$ = CYNew CYProperty($2, CYNew CYVariable($2)); }
830 | PropertyName ":" AssignmentExpression { $$ = CYNew CYProperty($1, $3); }
835 : IdentifierName { $$ = $1; }
836 | StringLiteral { $$ = $1; }
837 | NumericLiteral { $$ = $1; }
841 : LexSetRegExp PropertyName_ { $$ = $2; }
845 /* 11.2 Left-Hand-Side Expressions {{{ */
847 : "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYDirectMember(NULL, $3); }
848 | "." IdentifierName { $$ = CYNew CYDirectMember(NULL, CYNew CYString($2)); }
849 | "." AutoComplete { driver.mode_ = CYDriver::AutoDirect; YYACCEPT; }
853 : MemberExpression { $$ = $1; }
854 //| "super" { $$ = $1; }
858 : LexSetRegExp PrimaryExpression { $$ = $2; }
859 | LexSetRegExp FunctionExpression { $$ = $2; }
860 | MemberExpression_ { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
861 | LexSetRegExp "new" MemberExpression Arguments { $$ = CYNew cy::Syntax::New($3, $4); }
865 : MemberExpression { $$ = $1; }
866 | LexSetRegExp "new" NewExpression { $$ = CYNew cy::Syntax::New($3, NULL); }
875 : CallExpression_ Arguments { $$ = CYNew CYCall($1, $2); }
876 | CallExpression { driver.context_ = $1; } MemberAccess { $3->SetLeft($1); $$ = $3; }
880 : "(" LexPushInOff ArgumentListOpt ")" LexPopIn { $$ = $3; }
884 : "," ArgumentList { $$ = $2; }
889 : AssignmentExpression ArgumentList_ { $$ = CYNew CYArgument(NULL, $1, $2); }
893 : ArgumentList { $$ = $1; }
894 | LexSetRegExp { $$ = NULL; }
897 LeftHandSideExpression
898 : NewExpression { $$ = $1; }
899 | CallExpression { $$ = $1; }
902 /* 11.3 Postfix Expressions {{{ */
904 : %prec "" LeftHandSideExpression { $$ = $1; }
905 | LeftHandSideExpression "++" { $$ = CYNew CYPostIncrement($1); }
906 | LeftHandSideExpression "--" { $$ = CYNew CYPostDecrement($1); }
909 /* 11.4 Unary Operators {{{ */
911 : "delete" UnaryExpression { $$ = CYNew CYDelete($2); }
912 | "void" UnaryExpression { $$ = CYNew CYVoid($2); }
913 | "typeof" UnaryExpression { $$ = CYNew CYTypeOf($2); }
914 | "++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
915 | "\n++" UnaryExpression { $$ = CYNew CYPreIncrement($2); }
916 | "--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
917 | "\n--" UnaryExpression { $$ = CYNew CYPreDecrement($2); }
918 | "+" UnaryExpression { $$ = CYNew CYAffirm($2); }
919 | "-" UnaryExpression { $$ = CYNew CYNegate($2); }
920 | "~" UnaryExpression { $$ = CYNew CYBitwiseNot($2); }
921 | "!" UnaryExpression { $$ = CYNew CYLogicalNot($2); }
925 : PostfixExpression { $$ = $1; }
926 | LexSetRegExp UnaryExpression_ { $$ = $2; }
929 /* 11.5 Multiplicative Operators {{{ */
930 MultiplicativeExpression
931 : UnaryExpression { $$ = $1; }
932 | MultiplicativeExpression "*" UnaryExpression { $$ = CYNew CYMultiply($1, $3); }
933 | MultiplicativeExpression "/" UnaryExpression { $$ = CYNew CYDivide($1, $3); }
934 | MultiplicativeExpression "%" UnaryExpression { $$ = CYNew CYModulus($1, $3); }
937 /* 11.6 Additive Operators {{{ */
939 : MultiplicativeExpression { $$ = $1; }
940 | AdditiveExpression "+" MultiplicativeExpression { $$ = CYNew CYAdd($1, $3); }
941 | AdditiveExpression "-" MultiplicativeExpression { $$ = CYNew CYSubtract($1, $3); }
944 /* 11.7 Bitwise Shift Operators {{{ */
946 : AdditiveExpression { $$ = $1; }
947 | ShiftExpression "<<" AdditiveExpression { $$ = CYNew CYShiftLeft($1, $3); }
948 | ShiftExpression ">>" AdditiveExpression { $$ = CYNew CYShiftRightSigned($1, $3); }
949 | ShiftExpression ">>>" AdditiveExpression { $$ = CYNew CYShiftRightUnsigned($1, $3); }
952 /* 11.8 Relational Operators {{{ */
954 : ShiftExpression { $$ = $1; }
955 | RelationalExpression "<" ShiftExpression { $$ = CYNew CYLess($1, $3); }
956 | RelationalExpression ">" ShiftExpression { $$ = CYNew CYGreater($1, $3); }
957 | RelationalExpression "<=" ShiftExpression { $$ = CYNew CYLessOrEqual($1, $3); }
958 | RelationalExpression ">=" ShiftExpression { $$ = CYNew CYGreaterOrEqual($1, $3); }
959 | RelationalExpression "instanceof" ShiftExpression { $$ = CYNew CYInstanceOf($1, $3); }
960 | RelationalExpression "in" ShiftExpression { $$ = CYNew CYIn($1, $3); }
963 /* 11.9 Equality Operators {{{ */
965 : RelationalExpression { $$ = $1; }
966 | EqualityExpression "==" RelationalExpression { $$ = CYNew CYEqual($1, $3); }
967 | EqualityExpression "!=" RelationalExpression { $$ = CYNew CYNotEqual($1, $3); }
968 | EqualityExpression "===" RelationalExpression { $$ = CYNew CYIdentical($1, $3); }
969 | EqualityExpression "!==" RelationalExpression { $$ = CYNew CYNotIdentical($1, $3); }
972 /* 11.10 Binary Bitwise Operators {{{ */
974 : EqualityExpression { $$ = $1; }
975 | BitwiseANDExpression "&" EqualityExpression { $$ = CYNew CYBitwiseAnd($1, $3); }
979 : BitwiseANDExpression { $$ = $1; }
980 | BitwiseXORExpression "^" BitwiseANDExpression { $$ = CYNew CYBitwiseXOr($1, $3); }
984 : BitwiseXORExpression { $$ = $1; }
985 | BitwiseORExpression "|" BitwiseXORExpression { $$ = CYNew CYBitwiseOr($1, $3); }
988 /* 11.11 Binary Logical Operators {{{ */
990 : BitwiseORExpression { $$ = $1; }
991 | LogicalANDExpression "&&" BitwiseORExpression { $$ = CYNew CYLogicalAnd($1, $3); }
995 : LogicalANDExpression { $$ = $1; }
996 | LogicalORExpression "||" LogicalANDExpression { $$ = CYNew CYLogicalOr($1, $3); }
999 /* 11.12 Conditional Operator ( ? : ) {{{ */
1000 ConditionalExpression
1001 : LogicalORExpression { $$ = $1; }
1002 | LogicalORExpression "?" LexPushInOff AssignmentExpression ":" LexPopIn AssignmentExpression { $$ = CYNew CYCondition($1, $4, $7); }
1005 /* 11.13 Assignment Operators {{{ */
1006 AssignmentExpression
1007 : ConditionalExpression { $$ = $1; }
1008 | ArrowFunction { $$ = $1; }
1009 | LeftHandSideExpression "=" AssignmentExpression { $$ = CYNew CYAssign($1, $3); }
1010 | LeftHandSideExpression "*=" AssignmentExpression { $$ = CYNew CYMultiplyAssign($1, $3); }
1011 | LeftHandSideExpression "/=" AssignmentExpression { $$ = CYNew CYDivideAssign($1, $3); }
1012 | LeftHandSideExpression "%=" AssignmentExpression { $$ = CYNew CYModulusAssign($1, $3); }
1013 | LeftHandSideExpression "+=" AssignmentExpression { $$ = CYNew CYAddAssign($1, $3); }
1014 | LeftHandSideExpression "-=" AssignmentExpression { $$ = CYNew CYSubtractAssign($1, $3); }
1015 | LeftHandSideExpression "<<=" AssignmentExpression { $$ = CYNew CYShiftLeftAssign($1, $3); }
1016 | LeftHandSideExpression ">>=" AssignmentExpression { $$ = CYNew CYShiftRightSignedAssign($1, $3); }
1017 | LeftHandSideExpression ">>>=" AssignmentExpression { $$ = CYNew CYShiftRightUnsignedAssign($1, $3); }
1018 | LeftHandSideExpression "&=" AssignmentExpression { $$ = CYNew CYBitwiseAndAssign($1, $3); }
1019 | LeftHandSideExpression "^=" AssignmentExpression { $$ = CYNew CYBitwiseXOrAssign($1, $3); }
1020 | LeftHandSideExpression "|=" AssignmentExpression { $$ = CYNew CYBitwiseOrAssign($1, $3); }
1023 /* 11.14 Comma Operator {{{ */
1025 : "," Expression { $$ = $2; }
1026 | { $$ = CYNew CYCompound(); }
1030 : AssignmentExpression Expression_ { $2->AddPrev($1); $$ = $2; }
1034 : Expression { $$ = $1; }
1035 | LexSetRegExp { $$ = NULL; }
1039 /* 12 Statements {{{ */
1041 : Block { $$ = $1; }
1042 | VariableStatement { $$ = $1; }
1043 | EmptyStatement { $$ = $1; }
1044 | IfStatement { $$ = $1; }
1045 | BreakableStatement { $$ = $1; }
1046 | ContinueStatement { $$ = $1; }
1047 | BreakStatement { $$ = $1; }
1048 | ReturnStatement { $$ = $1; }
1049 | WithStatement { $$ = $1; }
1050 | LabelledStatement { $$ = $1; }
1051 | ThrowStatement { $$ = $1; }
1052 | TryStatement { $$ = $1; }
1053 | DebuggerStatement { $$ = $1; }
1057 : LexSetRegExp Statement__ { $$ = $2; }
1058 | ExpressionStatement { $$ = $1; }
1062 : LexSetStatement Statement_ { $$ = $2; }
1066 : FunctionDeclaration { $$ = $1; }
1067 | LexicalDeclaration { $$ = $1; }
1071 : LexSetRegExp Declaration__ { $$ = $2; }
1075 : LexSetStatement Declaration_ { $$ = $2; }
1079 : IterationStatement { $$ = $1; }
1080 | SwitchStatement { $$ = $1; }
1083 /* 12.1 Block {{{ */
1085 : BRACE StatementListOpt "}" { $$ = $2; }
1089 : ";{" StatementListOpt "}" { $$ = CYNew CYBlock($2); }
1093 : StatementListItem StatementListOpt { $1->SetNext($2); $$ = $1; }
1097 : StatementList { $$ = $1; }
1098 | LexSetStatement LexSetRegExp { $$ = NULL; }
1102 : Statement { $$ = $1; }
1103 | Declaration { $$ = $1; }
1107 /* 12.2 Declarations {{{ */
1109 : Identifier { $$ = $1; }
1116 // XXX: BindingPattern
1118 /* 12.2.1 Let and Const Declarations {{{ */
1120 : LetOrConst VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1128 /* 12.2.2 Variable Statement {{{ */
1130 : Var_ VariableDeclarationList Terminator { $$ = CYNew CYVar($2); }
1133 VariableDeclarationList_
1134 : "," VariableDeclarationList { $$ = $2; }
1138 VariableDeclarationList
1139 : VariableDeclaration VariableDeclarationList_ { $$ = CYNew CYDeclarations($1, $2); }
1143 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1144 // XXX: | BindingPattern Initialiser { $$ = CYNew CYDeclaration($1, $2); }
1148 : "=" AssignmentExpression { $$ = $2; }
1152 : Initialiser { $$ = $1; }
1156 /* 12.2.4 Destructuring Binding Patterns {{{ */
1160 : SingleNameBinding { $$ = $1; }
1164 : BindingIdentifier InitialiserOpt { $$ = CYNew CYDeclaration($1, $2); }
1168 /* 12.3 Empty Statement {{{ */
1170 : ";" { $$ = CYNew CYEmpty(); }
1173 /* 12.4 Expression Statement {{{ */
1175 : Expression Terminator { $$ = CYNew CYExpress($1); }
1178 /* 12.5 The if Statement {{{ */
1180 : "else" Statement { $$ = $2; }
1181 | %prec "if" { $$ = NULL; }
1185 : "if" "(" Expression ")" Statement ElseStatementOpt { $$ = CYNew CYIf($3, $5, $6); }
1189 /* 12.6.1 The do-while Statement {{{ */
1191 : "do" Statement "while" "(" Expression ")" TerminatorOpt { $$ = CYNew CYDoWhile($5, $2); }
1194 /* 12.6.2 The while Statement {{{ */
1196 : "while" "(" Expression ")" Statement { $$ = CYNew CYWhile($3, $5); }
1199 /* 12.6.3 The for Statement {{{ */
1201 : "for" "(" LexPushInOn ForStatementInitialiser ";" LexPopIn ExpressionOpt ";" ExpressionOpt ")" Statement { $$ = CYNew CYFor($4, $7, $9, $11); }
1204 ForStatementInitialiser
1205 : ExpressionOpt { $$ = $1; }
1206 | LexSetRegExp Var_ VariableDeclarationList { $$ = CYNew CYForDeclarations($3); }
1209 /* 12.6.4 The for-in and for-of Statements {{{ */
1211 : "for" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForIn($4, $7, $9); }
1212 | "for" "(" LexPushInOn ForInStatementInitialiser "of" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($4, $7, $9); }
1215 ForInStatementInitialiser
1216 : LeftHandSideExpression { $$ = $1; }
1217 | LexSetRegExp Var_ VariableDeclaration { $$ = $3; }
1221 /* 12.7 The continue Statement {{{ */
1223 : "continue" "\n" StrictSemi { $$ = CYNew CYContinue(NULL); }
1224 | "continue" IdentifierOpt Terminator { $$ = CYNew CYContinue($2); }
1227 /* 12.8 The break Statement {{{ */
1229 : "break" "\n" StrictSemi { $$ = CYNew CYBreak(NULL); }
1230 | "break" IdentifierOpt Terminator { $$ = CYNew CYBreak($2); }
1233 /* 12.9 The return Statement {{{ */
1235 : "return" LexSetRegExp "\n" StrictSemi { $$ = CYNew CYReturn(NULL); }
1236 | "return" ExpressionOpt Terminator { $$ = CYNew CYReturn($2); }
1239 /* 12.10 The with Statement {{{ */
1241 : "with" "(" Expression ")" Statement { $$ = CYNew CYWith($3, $5); }
1245 /* 12.11 The switch Statement {{{ */
1247 : "switch" "(" Expression ")" CaseBlock { $$ = CYNew CYSwitch($3, $5); }
1251 : BRACE CaseClausesOpt "}" { $$ = $2; }
1255 : "case" Expression ":" StatementListOpt { $$ = CYNew CYClause($2, $4); }
1259 : CaseClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1260 | DefaultClause CaseClausesOpt { $1->SetNext($2); $$ = $1; }
1265 : "default" ":" StatementListOpt { $$ = CYNew CYClause(NULL, $3); }
1268 /* 12.12 Labelled Statements {{{ */
1270 : Identifier ":" Statement { $$ = CYNew CYLabel($1, $3); }
1273 /* 12.13 The throw Statement {{{ */
1275 : "throw" LexSetRegExp "\n" StrictSemi { YYABORT; }
1276 | "throw" Expression Terminator { $$ = CYNew cy::Syntax::Throw($2); }
1279 /* 12.14 The try Statement {{{ */
1281 : "try" Block_ CatchOpt FinallyOpt { $$ = CYNew cy::Syntax::Try($2, $3, $4); }
1285 : "catch" "(" Identifier ")" Block_ { $$ = CYNew cy::Syntax::Catch($3, $5); }
1290 : "finally" Block_ { $$ = CYNew CYFinally($2); }
1294 /* 12.14 The debugger Statement {{{ */
1296 : "debugger" Terminator { $$ = CYNew CYDebugger(); }
1300 /* 13.1 Function Definitions {{{ */
1302 : ";function" Identifier "(" FormalParameterListOpt ")" BRACE FunctionBody "}" { $$ = CYNew CYFunctionStatement($2, $4, $7); }
1306 : "function" IdentifierOpt "(" LexPushInOff FormalParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYFunctionExpression($2, $5, $10); }
1309 FormalParameterList_
1310 : "," FormalParameterList { $$ = $2; }
1315 // XXX: : FunctionRestParameter { $$ = $1; }
1316 : FormalParameter FormalParameterList_ { $$ = CYNew CYFunctionParameter($1, $2); }
1319 FormalParameterListOpt
1320 : FormalParameterList
1324 /* XXX: FunctionRestParameter
1325 : "..." BindingIdentifier { $$ = CYNew CYFunctionRestParameter($2); }
1329 : BindingElement { $$ = $1; }
1333 : StatementListOpt { $$ = $1; }
1336 /* 13.2 Arrow Function Definitions {{{ */
1338 : LexSetRegExp ArrowParameters "=>" LexNoBrace ConciseBody { $$ = CYNew CYFatArrow($2, $5); }
1342 : BindingIdentifier { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1)); }
1343 //| ParentheticalOpt { $$ = $1; }
1347 : AssignmentExpression { $$ = CYNew CYReturn($1); }
1348 | LexSetRegExp ";{" LexPushInOff FunctionBody "}" LexPopIn { $$ = $4; }
1351 /* 14 Program {{{ */
1353 : ProgramBodyOpt { driver.program_ = CYNew CYProgram($1); }
1357 : StatementList { $$ = $1; }
1361 : ProgramBody { $$ = $1; }
1362 | LexSetStatement LexSetRegExp { $$ = NULL; }
1367 /* Cycript (Objective-C): Type Encoding {{{ */
1369 : "(" PrefixedType ")" { $$ = $2; }
1373 : Identifier { $$ = CYNew CYTypedIdentifier($1); }
1378 : ArrayedType "[" NumericLiteral "]" { $$ = $1; CYSetLast($$->type_) = CYNew CYTypeArrayOf($3); }
1379 | TypeSignifier { $$ = $1; }
1380 | { $$ = CYNew CYTypedIdentifier(NULL); }
1384 : ArrayedType { $$ = $1; }
1385 | TypeParenthetical "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $1; CYSetLast($$->type_) = CYNew CYTypeFunctionWith($4); }
1389 : "*" TypeQualifierRight PrefixedType { $$ = $3; CYSetLast($$->type_) = $2; CYSetLast($$->type_) = CYNew CYTypePointerTo(); }
1390 | SuffixedType { $$ = $1; }
1394 : "const" TypeQualifierLeft { $$ = CYNew CYTypeConstant(); CYSetLast($$) = $2; }
1399 : TypeQualifierRight "const" { $$ = CYNew CYTypeConstant($1); }
1404 : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; CYSetLast($$) = $1; CYSetLast($$) = CYNew CYTypeVariable($2); }
1408 : Variable { $$ = $1; }
1409 | "void" { $$ = CYNew cy::Syntax::New(CYNew CYVariable(CYNew CYIdentifier("Type")), CYNew CYArgument(CYNew CYString("v"))); }
1413 : ConcreteType PrefixedType { $$ = $2; CYSetLast($$->type_) = $1; }
1417 : TypedIdentifier { $$ = CYNew CYEncodedType($1->type_); }
1421 : TypeQualifierLeft PrimitiveType { $$ = $1; CYSetLast($$) = CYNew CYTypeVariable($2); }
1422 | ModifiedType "*" { $$ = CYNew CYTypePointerTo($1); }
1426 : ModifiedType_ TypeQualifierRight { $$ = $2; CYSetLast($$) = $1; }
1430 : AtEncode "(" EncodedType ")" { $$ = $3; }
1433 /* Cycript (Objective-C): @class Declaration {{{ */
1435 /* XXX: why the hell did I choose MemberExpression? */
1436 : ":" LexSetRegExp MemberExpression { $$ = $3; }
1441 : Expression Identifier ";" ClassFieldListOpt { $$ = CYNew CYField($1, $2, $4); }
1442 | LexSetRegExp { $$ = NULL; }
1446 : BRACE ClassFieldListOpt "}" { $$ = $2; }
1450 : "+" { $$ = false; }
1451 | "-" { $$ = true; }
1455 : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
1460 : Word ":" TypeOpt Identifier { $$ = CYNew CYMessageParameter($1, $3, $4); }
1463 MessageParameterList
1464 : MessageParameter MessageParameterListOpt { $1->SetNext($2); $$ = $1; }
1467 MessageParameterListOpt
1468 : MessageParameterList { $$ = $1; }
1473 : MessageParameterList { $$ = $1; }
1474 | Word { $$ = CYNew CYMessageParameter($1, NULL, NULL); }
1477 ClassMessageDeclaration
1478 : MessageScope TypeOpt MessageParameters BRACE FunctionBody "}" { $$ = CYNew CYMessage($1, $2, $3, $5); }
1481 ClassMessageDeclarationListOpt
1482 : ClassMessageDeclarationListOpt ClassMessageDeclaration { $2->SetNext($1); $$ = $2; }
1483 | ClassMessageDeclarationListOpt Comment { $$ = $1; }
1488 : Identifier { $$ = $1; }
1489 | "(" AssignmentExpression ")" { $$ = $2; }
1493 : ClassName { $$ = $1; }
1497 // XXX: this should be AssignmentExpressionNoRight
1499 : ShiftExpression ClassProtocolsOpt { $$ = CYNew CYProtocol($1, $2); }
1503 : "," ClassProtocols { $$ = $2; }
1507 ClassProtocolListOpt
1508 : "<" ClassProtocols ">" { $$ = $2; }
1513 : "@implementation" LexPushInOff ClassNameOpt ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" LexPopIn { $$ = CYNew CYClassExpression($3, $4, $5, $6, $7); }
1517 : ";@implementation" ClassName ClassSuperOpt ClassProtocolListOpt ClassFields ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYClassStatement($2, $3, $4, $5, $6); }
1525 : ";@implementation" ClassName CategoryName ClassMessageDeclarationListOpt "@end" { $$ = CYNew CYCategory($2, $4); }
1529 : ClassExpression { $$ = $1; }
1533 : ClassStatement { $$ = $1; }
1534 | CategoryStatement { $$ = $1; }
1537 /* Cycript (Objective-C): Send Message {{{ */
1539 : "," AssignmentExpression VariadicCall { $$ = CYNew CYArgument(NULL, $2, $3); }
1544 : WordOpt { driver.contexts_.back().words_.push_back($1); } { $$ = $1; }
1545 | AutoComplete { driver.mode_ = CYDriver::AutoMessage; YYACCEPT; }
1549 : SelectorCall { $$ = $1; }
1550 | VariadicCall { $$ = $1; }
1554 : SelectorWordOpt ":" AssignmentExpression SelectorCall_ { $$ = CYNew CYArgument($1 ?: CYNew CYBlank(), $3, $4); }
1558 : SelectorCall { $$ = $1; }
1559 | Word { $$ = CYNew CYArgument($1, NULL); }
1563 : "[" LexPushInOff AssignmentExpression { driver.contexts_.push_back($3); } SelectorList "]" LexPopIn { driver.contexts_.pop_back(); } { $$ = CYNew CYSendDirect($3, $5); }
1564 | "[" LexPushInOff LexSetRegExp "super" { driver.context_ = NULL; } SelectorList "]" LexPopIn { $$ = CYNew CYSendSuper($6); }
1568 : WordOpt ":" SelectorExpressionOpt { $$ = CYNew CYSelectorPart($1, true, $3); }
1572 : SelectorExpression_ { $$ = $1; }
1573 | Word { $$ = CYNew CYSelectorPart($1, false, NULL); }
1576 SelectorExpressionOpt
1577 : SelectorExpression_ { $$ = $1; }
1582 : MessageExpression { $$ = $1; }
1583 | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
1586 /* Cycript (Objective-C): @import Directive {{{ */
1600 : LexSetStatement LexSetRegExp "@import" ImportPath { $$ = CYNew CYImport(); }
1603 /* Cycript (Objective-C): Boxed Expressions {{{ */
1605 : NullLiteral { $$ = $1; }
1606 | BooleanLiteral { $$ = $1; }
1607 | NumericLiteral { $$ = $1; }
1608 | StringLiteral { $$ = $1; }
1609 | ArrayLiteral { $$ = $1; }
1610 | ObjectLiteral { $$ = $1; }
1611 | Parenthetical { $$ = $1; }
1615 : "@" BoxableExpression { $$ = CYNew CYBox($2); }
1618 /* Cycript (Objective-C): Block Expressions {{{ */
1620 : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
1626 /* Cycript (C): Pointer Indirection/Addressing {{{ */
1627 LeftHandSideExpression
1628 : LexSetRegExp "*" UnaryExpression { $$ = CYNew CYIndirect($3); }
1632 : "&" UnaryExpression { $$ = CYNew CYAddressOf($2); }
1636 : "->" "[" Expression "]" { $$ = CYNew CYIndirectMember(NULL, $3); }
1637 | "->" IdentifierName { $$ = CYNew CYIndirectMember(NULL, CYNew CYString($2)); }
1638 | "->" AutoComplete { driver.mode_ = CYDriver::AutoIndirect; YYACCEPT; }
1641 /* Cycript (C): auto Compatibility {{{ */
1646 /* Cycript (C): Lambda Expressions {{{ */
1648 : "," TypedParameterList { $$ = $2; }
1653 : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
1656 TypedParameterListOpt
1657 : TypedParameterList { $$ = $1; }
1662 : "[" LexPushInOff LexSetRegExp "&" LexSetRegExp "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" TypedIdentifier BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($14->type_, $10, $17); }
1665 /* Cycript (C): Type Definitions {{{ */
1667 : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
1672 /* YUI: Documentation Comments {{{ */
1674 : Comment { $$ = $1; }
1679 /* Lexer State {{{ */
1681 : { driver.PushCondition(CYDriver::RegExpCondition); }
1685 : { driver.PushCondition(CYDriver::XMLContentCondition); }
1689 : { driver.PushCondition(CYDriver::XMLTagCondition); }
1693 : { driver.PopCondition(); }
1697 : { driver.SetCondition(CYDriver::XMLContentCondition); }
1701 : { driver.SetCondition(CYDriver::XMLTagCondition); }
1704 /* Virtual Tokens {{{ */
1711 /* 8.1 Context Keywords {{{ */
1713 : "namespace" { $$ = $1; }
1714 | "xml" { $$ = $1; }
1717 /* 8.3 XML Initialiser Input Elements {{{ */
1719 : XMLComment { $$ = $1; }
1720 | XMLCDATA { $$ = $1; }
1721 | XMLPI { $$ = $1; }
1725 /* 11.1 Primary Expressions {{{ */
1727 : PropertyIdentifier { $$ = CYNew CYPropertyVariable($1); }
1728 | XMLInitialiser { $$ = $1; }
1729 | XMLListInitialiser { $$ = $1; }
1733 : AttributeIdentifier { $$ = $1; }
1734 | QualifiedIdentifier { $$ = $1; }
1735 | WildcardIdentifier { $$ = $1; }
1738 /* 11.1.1 Attribute Identifiers {{{ */
1740 : "@" QualifiedIdentifier_ { $$ = CYNew CYAttribute($2); }
1744 : PropertySelector { $$ = $1; }
1745 | "[" LexPushInOff Expression "]" LexPopIn { $$ = CYNew CYSelector($3); }
1749 : Identifier { $$ = CYNew CYSelector($1); }
1750 | WildcardIdentifier { $$ = $1; }
1753 /* 11.1.2 Qualified Identifiers {{{ */
1754 QualifiedIdentifier_
1755 : PropertySelector_ { $$ = CYNew CYQualified(NULL, $1); }
1756 | QualifiedIdentifier { $$ = $1; }
1760 : PropertySelector "::" PropertySelector_ { $$ = CYNew CYQualified($1, $3); }
1763 /* 11.1.3 Wildcard Identifiers {{{ */
1765 : "*" { $$ = CYNew CYWildcard(); }
1768 /* 11.1.4 XML Initialiser {{{ */
1770 : XMLMarkup { $$ = $1; }
1771 | XMLElement { $$ = $1; }
1775 : "<" LexPushInOff XMLTagContent LexPop "/>" LexPopIn
1776 | "<" LexPushInOff XMLTagContent ">" LexSetXMLContent XMLElementContentOpt "</" LexSetXMLTag XMLTagName XMLWhitespaceOpt LexPop ">" LexPopIn
1780 : LexPushXMLTag XMLTagName XMLAttributes
1784 : BRACE LexPushRegExp Expression LexPop "}"
1793 : XMLAttributes_ XMLAttribute
1798 : XMLAttributes_ XMLWhitespace XMLExpression XMLWhitespaceOpt
1799 | XMLAttributes_ XMLWhitespaceOpt
1808 : XMLWhitespace XMLName XMLWhitespaceOpt "=" XMLWhitespaceOpt XMLAttributeValue_
1812 : XMLExpression XMLElementContentOpt
1813 | XMLMarkup XMLElementContentOpt
1814 | XMLText XMLElementContentOpt
1815 | XMLElement XMLElementContentOpt
1818 XMLElementContentOpt
1823 /* 11.1.5 XMLList Initialiser {{{ */
1825 : "<>" LexPushInOff LexPushXMLContent XMLElementContent LexPop "</>" LexPopIn { $$ = CYNew CYXMLList($4); }
1829 /* 11.2 Left-Hand-Side Expressions {{{ */
1831 : Identifier { $$ = $1; }
1832 | PropertyIdentifier { $$ = $1; }
1836 : "." PropertyIdentifier { $$ = CYNew CYPropertyMember(NULL, $2); }
1837 | ".." PropertyIdentifier_ { $$ = CYNew CYDescendantMember(NULL, $2); }
1838 | "." "(" Expression ")" { $$ = CYNew CYFilteringPredicate(NULL, $3); }
1841 /* 12.1 The default xml namespace Statement {{{ */
1842 /* XXX: DefaultXMLNamespaceStatement
1843 : "default" "xml" "namespace" "=" Expression Terminator { $$ = CYNew CYDefaultXMLNamespace($5); }
1847 : DefaultXMLNamespaceStatement { $$ = $1; }
1852 /* JavaScript 1.7: Array Comprehensions {{{ */
1854 : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
1858 : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
1859 | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
1863 : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
1866 ComprehensionListOpt
1867 : ComprehensionList { $$ = $1; }
1868 | IfComprehension { $$ = $1; }
1873 : "[" LexPushInOff AssignmentExpression ComprehensionList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
1876 /* JavaScript 1.7: for each {{{ */
1878 : "for" "each" "(" LexPushInOn ForInStatementInitialiser "!in" LexPopIn Expression ")" Statement { $$ = CYNew CYForOf($5, $8, $10); }
1881 /* JavaScript 1.7: let Statements {{{ */
1883 : "let" "(" VariableDeclarationList ")" Statement { $$ = CYNew CYLetStatement($3, $5); }
1891 /* JavaScript FTW: Ruby Blocks {{{ */
1892 RubyProcParameterList_
1893 : "," RubyProcParameterList { $$ = $2; }
1897 RubyProcParameterList
1898 : Identifier RubyProcParameterList_ { $$ = CYNew CYFunctionParameter(CYNew CYDeclaration($1), $2); }
1903 : "|" RubyProcParameterList "|" { $$ = $2; }
1904 | "||" { $$ = NULL; }
1907 RubyProcParametersOpt
1908 : RubyProcParameters
1913 : "{" RubyProcParametersOpt StatementListOpt "}" { $$ = CYNew CYRubyProc($2, $3); }
1917 : "{" LexPushInOff RubyProcParameters StatementListOpt "}" LexPopIn { $$ = CYNew CYRubyProc($3, $4); }
1921 : CallExpression_ RubyProcExpression { $$ = CYNew CYRubyBlock($1, $2); }