]> git.saurik.com Git - cycript.git/blobdiff - Cycript.yy.in
Expose the internal Type of Pointers through type.
[cycript.git] / Cycript.yy.in
index 89ed1a9d0577d2f26e4040147d5ab62c4d1c94fe..a11643f13e89573e01cd27a71c9538af67afaaf4 100644 (file)
@@ -160,6 +160,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
 
 @begin E4X ObjectiveC
 %token At "@"
+%token Pound "#"
 @end
 
 %token Ampersand "&"
@@ -347,6 +348,8 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <argument_> ArgumentList
 %type <argument_> ArgumentListOpt
 %type <argument_> Arguments
+%type <expression_> ArrayComprehension
+%type <expression_> ArrayInitialiser
 %type <literal_> ArrayLiteral
 %type <expression_> ArrowFunction
 %type <functionParameter_> ArrowParameters
@@ -368,10 +371,10 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <clause_> CaseClause
 %type <clause_> CaseClausesOpt
 %type <catch_> CatchOpt
-%type <comprehension_> ComprehensionForList
-%type <comprehension_> ComprehensionForListOpt
-%type <comprehension_> ComprehensionList
-%type <comprehension_> ComprehensionListOpt
+%type <expression_> Comprehension
+%type <comprehension_> ComprehensionFor
+%type <comprehension_> ComprehensionIf
+%type <comprehension_> ComprehensionTail
 %type <expression_> ConditionalExpression
 %type <statement_> ContinueStatement
 %type <statement_> ConciseBody
@@ -392,7 +395,6 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <expression_> ExpressionOpt
 %type <statement_> ExpressionStatement
 %type <finally_> FinallyOpt
-%type <comprehension_> ForComprehension
 %type <for_> ForStatementInitialiser
 %type <forin_> ForInStatementInitialiser
 %type <declaration_> FormalParameter
@@ -405,7 +407,6 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <identifier_> Identifier
 %type <identifier_> IdentifierOpt
 %type <word_> IdentifierName
-%type <comprehension_> IfComprehension
 %type <statement_> IfStatement
 %type <expression_> Initialiser
 %type <expression_> InitialiserOpt
@@ -763,13 +764,19 @@ PrimaryExpression
     : "this" { $$ = $1; }
     | Variable { $$ = $1; }
     | Literal { $$ = $1; }
-    | ArrayLiteral { $$ = $1; }
+    | ArrayInitialiser { $$ = $1; }
     | ObjectLiteral { $$ = $1; }
     | Parenthetical { $$ = $1; }
     | AutoComplete { driver.mode_ = CYDriver::AutoPrimary; YYACCEPT; }
     ;
 /* }}} */
-/* 11.1.4.1 Array Initialiser {{{ */
+/* 11.1.4 Array Initializer {{{ */
+ArrayInitialiser
+    : ArrayLiteral { $$ = $1; }
+    | ArrayComprehension { $$ = $1; }
+    ;
+/* }}} */
+/* 11.1.4.1 Array Literal {{{ */
 ArrayLiteral
     : "[" LexPushInOff ElementListOpt "]" LexPopIn { $$ = CYNew CYArray($3); }
     ;
@@ -794,19 +801,26 @@ ElementListOpt
     ;
 /* }}} */
 /* 11.1.4.2 Array Comprehension {{{ */
-PrimaryExpression
-    : "[" LexPushInOff AssignmentExpression ComprehensionForList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
+ArrayComprehension
+    : "[" LexPushInOff Comprehension "]" LexPopIn { $$ = $3; }
     ;
 
-ComprehensionForList
-    : "for" Binding "in" Expression ComprehensionForListOpt { $$ = CYNew CYForInComprehension($2, $4, $5); }
-    | "for" Binding "of" Expression ComprehensionForListOpt { $$ = CYNew CYForOfComprehension($2, $4, $5); }
+Comprehension
+    : LexSetRegExp ComprehensionFor ComprehensionTail AssignmentExpression { $$ = CYNew CYArrayComprehension($4, $2->Modify($3)); }
     ;
 
-ComprehensionForListOpt
-    : ComprehensionForList { $$ = $1; }
-    | "if" Expression { $$ = CYNew CYIfComprehension($2); }
-    | { $$ = NULL; }
+ComprehensionTail
+    : { $$ = NULL; }
+    | ComprehensionFor ComprehensionTail { $$ = $1->Modify($2); }
+    | ComprehensionIf ComprehensionTail { $$ = $1->Modify($2); }
+    ;
+
+ComprehensionFor
+    : "for" "(" Binding "of" Expression ")" { $$ = CYNew CYForOfComprehension($3, $5); }
+    ;
+
+ComprehensionIf
+    : "if" "(" AssignmentExpression ")" { $$ = CYNew CYIfComprehension($3); }
     ;
 /* }}} */
 /* 11.1.5 Object Initialiser {{{ */
@@ -1391,6 +1405,7 @@ FunctionedType
 
 SuffixedType
     : ArrayedType { $$ = $1; }
+    | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
     | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
     | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
     ;
@@ -1848,27 +1863,13 @@ Statement__
 @end
 
 /* JavaScript 1.7: Array Comprehensions {{{ */
-IfComprehension
-    : "if" "(" Expression ")" { $$ = CYNew CYIfComprehension($3); }
+Comprehension
+    : AssignmentExpression ComprehensionFor ComprehensionTail { $$ = CYNew CYArrayComprehension($1, $2->Modify($3)); }
     ;
 
-ForComprehension
-    : "for" "(" Identifier "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
-    | "for" "each" "(" Identifier "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
-    ;
-
-ComprehensionList
-    : ForComprehension ComprehensionListOpt { $1->SetNext($2); $$ = $1; }
-    ;
-
-ComprehensionListOpt
-    : ComprehensionList { $$ = $1; }
-    | IfComprehension { $$ = $1; }
-    | { $$ = NULL; }
-    ;
-
-PrimaryExpression
-    : "[" LexPushInOff AssignmentExpression ComprehensionList "]" LexPopIn { $$ = CYNew CYArrayComprehension($3, $4); }
+ComprehensionFor
+    : "for" "(" Binding "in" Expression ")" { $$ = CYNew CYForInComprehension($3, $5); }
+    | "for" "each" "(" Binding "in" Expression ")" { $$ = CYNew CYForOfComprehension($4, $6); }
     ;
 /* }}} */
 /* JavaScript 1.7: for each {{{ */