]> git.saurik.com Git - cycript.git/blobdiff - Cycript.yy.in
On iOS 9 Apple broke pre-existing 32-bit binaries.
[cycript.git] / Cycript.yy.in
index 9aea79d36a445a47a16956a6efed199025f40e13..b2f56299b09274dee2fae9221cb7cb3c6c31fffd 100644 (file)
@@ -1,21 +1,21 @@
 /* Cycript - Optimizing JavaScript Compiler/Runtime
- * Copyright (C) 2009-2013  Jay Freeman (saurik)
+ * Copyright (C) 2009-2014  Jay Freeman (saurik)
 */
 
-/* GNU General Public License, Version 3 {{{ */
+/* GNU Affero General Public License, Version 3 {{{ */
 /*
- * Cycript is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, either version 3 of the License,
- * or (at your option) any later version.
- *
- * Cycript is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Cycript.  If not, see <http://www.gnu.org/licenses/>.
+ * GNU Affero General Public License for more details.
+
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 **/
 /* }}} */
 
@@ -110,12 +110,17 @@ typedef struct {
 } YYSTYPE;
 
 #define YYSTYPE YYSTYPE
-@if Bison24 }
 
 @if Bison24 %code provides {
 int cylex(YYSTYPE *, cy::location *, void *);
 @if Bison24 }
 
+@if Bison23 %}
+@if Bison23 %union {
+@if Bison23 }
+@if Bison23 %{
+
+@if Bison24 }
 @if Bison23 %}
 
 %name-prefix="cy"
@@ -240,6 +245,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %token <identifier_> Typedef "typedef"
 %token <identifier_> Unsigned "unsigned"
 %token <identifier_> Signed "signed"
+%token <identifier_> Extern "extern"
 @end
 
 @begin C
@@ -481,7 +487,6 @@ int cylex(YYSTYPE *, cy::location *, void *);
 
 @begin C
 %type <typedIdentifier_> ArrayedType
-%type <expression_> EncodedType
 %type <modifier_> FunctionedType
 %type <specifier_> IntegerType
 %type <specifier_> IntegerTypeOpt
@@ -527,7 +532,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <selector_> SelectorExpressionOpt
 %type <argument_> SelectorList
 %type <word_> SelectorWordOpt
-%type <expression_> TypeOpt
+%type <typedIdentifier_> TypeOpt
 %type <argument_> VariadicCall
 @end
 
@@ -714,6 +719,7 @@ Identifier
     | "typedef" { $$ = $1; }
     | "unsigned" { $$ = $1; }
     | "signed" { $$ = $1; }
+    | "extern" { $$ = $1; }
 @end
 @begin ObjectiveC
     | "YES" { $$ = $1; }
@@ -1430,6 +1436,7 @@ SuffixedType
     : ArrayedType { $$ = $1; }
     | "(" LexPushInOff "^" TypeQualifierRight ")" LexPopIn "(" LexPushInOff TypedParameterListOpt ")" LexPopIn { $$ = $4; $$->modifier_ = CYNew CYTypeBlockWith($9, $$->modifier_); }
     | TypeParenthetical FunctionedType { $$ = $1; CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
+    | IdentifierType FunctionedType { $$ = CYNew CYTypedIdentifier($1); CYSetLast($2) = $$->modifier_; $$->modifier_ = $2; }
     | FunctionedType { $$ = CYNew CYTypedIdentifier(); CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
     ;
 
@@ -1476,12 +1483,8 @@ TypedIdentifier
     : TypeQualifierLeft PrimitiveType TypeQualifierRight { $$ = $3; $$->specifier_ = $2; CYSetLast($1) = $$->modifier_; $$->modifier_ = $1; }
     ;
 
-EncodedType
-    : TypedIdentifier { $$ = CYNew CYEncodedType($1); }
-    ;
-
 PrimaryExpression
-    : "@encode" "(" EncodedType ")" { $$ = $3; }
+    : "@encode" "(" TypedIdentifier ")" { $$ = CYNew CYEncodedType($3); }
     ;
 /* }}} */
 @end
@@ -1509,7 +1512,7 @@ MessageScope
     ;
 
 TypeOpt
-    : "(" LexSetRegExp EncodedType ")" { $$ = $3; }
+    : "(" LexSetRegExp TypedIdentifier ")" { $$ = $3; }
     | { $$ = NULL; }
     ;
 
@@ -1730,9 +1733,15 @@ PrimaryExpression
 /* }}} */
 /* Cycript (C): Type Definitions {{{ */
 Statement__
-    : "typedef" TypedIdentifier Terminator { $$ = CYNew CYTypeDefinition($2); }
+    : "typedef" TypedIdentifier { if ($2->identifier_ == NULL) YYABORT; } Terminator { $$ = CYNew CYTypeDefinition($2); }
+    ;
+/* }}} */
+/* Cycript (C): extern "C" {{{ */
+Statement__
+    : "extern" StringLiteral { if (strcmp($2->Value(), "C") != 0) YYABORT; } TypedIdentifier Terminator { $$ = CYNew CYExternal($2, $4); }
     ;
 /* }}} */
+
 @end
 
 /* YUI: Documentation Comments {{{ */