]> git.saurik.com Git - cycript.git/blobdiff - Cycript.yy.in
Add syntax to support C-style typedef assignment.
[cycript.git] / Cycript.yy.in
index 53673a2a0e3f0bfd1251ba0ef1d65d4cf4addeaf..8adbbf5fe96c0431db20311601e0e1f90db9eafc 100644 (file)
@@ -230,6 +230,10 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %token AtClass "@class"
 @end
 
+@begin C
+%token <identifier_> Typedef "typedef"
+@end
+
 @begin ObjectiveC
 %token AtImplementation "@implementation"
 %token AtImplementation_ ";@implementation"
@@ -645,6 +649,10 @@ WordOpt
 Identifier
     : Identifier_ { $$ = $1; }
 
+@begin C
+    | "typedef" { $$ = $1; }
+@end
+
     | "implements" { $$ = $1; }
     | "interface" { $$ = $1; }
     | "package" { $$ = $1; }
@@ -1577,20 +1585,6 @@ PrimaryExpression
     ;
 /* }}} */
 /* Cycript (Objective-C): Block Expressions {{{ */
-TypedParameterList_
-    : "," TypedParameterList { $$ = $2; }
-    | { $$ = NULL; }
-    ;
-
-TypedParameterList
-    : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
-    ;
-
-TypedParameterListOpt
-    : TypedParameterList { $$ = $1; }
-    | { $$ = NULL; }
-    ;
-
 PrimaryExpression
     : "^" ModifiedType "(" LexPushInOff TypedParameterListOpt ")" LexPopIn BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYObjCBlock($2, $5, $10); }
     ;
@@ -1618,6 +1612,30 @@ Var_
     : "auto"
     ;
 /* }}} */
+/* Cycript (C): Lambda Expressions {{{ */
+TypedParameterList_
+    : "," TypedParameterList { $$ = $2; }
+    | { $$ = NULL; }
+    ;
+
+TypedParameterList
+    : TypedIdentifier TypedParameterList_ { $$ = CYNew CYTypedParameter($1, $2); }
+    ;
+
+TypedParameterListOpt
+    : TypedParameterList { $$ = $1; }
+    | { $$ = NULL; }
+    ;
+
+PrimaryExpression
+    : "[" LexPushInOff LexSetRegExp "=" "]" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn "->" ModifiedType BRACE LexPushInOff FunctionBody "}" LexPopIn { $$ = CYNew CYLambda($13, $9, $16); }
+    ;
+/* }}} */
+/* Cycript (C): Type Definitions {{{ */
+Statement__
+    : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
+    ;
+/* }}} */
 @end
 
 /* YUI: Documentation Comments {{{ */