]> git.saurik.com Git - cycript.git/commitdiff
Repair support for compiling without Objective-C.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 11 Oct 2014 09:10:13 +0000 (02:10 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Sat, 11 Oct 2014 09:10:13 +0000 (02:10 -0700)
Cycript.yy.in
ObjectiveC/Output.cpp
ObjectiveC/Replace.cpp
ObjectiveC/Syntax.hpp
Output.cpp
Parser.hpp
Replace.cpp

index 3a31f1ebbe797f220e5cf17bb7123ecc846eb4fb..0f16b6e98f31b6ab711dc72d6ce9e08df6d67779 100644 (file)
@@ -79,13 +79,19 @@ typedef struct {
         CYProperty *property_;
         CYPropertyName *propertyName_;
         CYRubyProc *rubyProc_;
-        CYTypeSpecifier *specifier_;
         CYStatement *statement_;
         CYString *string_;
         CYThis *this_;
         CYTrue *true_;
         CYWord *word_;
 
+@begin C
+        CYTypeModifier *modifier_;
+        CYTypeSpecifier *specifier_;
+        CYTypedIdentifier *typedIdentifier_;
+        CYTypedParameter *typedParameter_;
+@end
+
 @begin ObjectiveC
         CYClassName *className_;
         CYField *field_;
@@ -93,9 +99,6 @@ typedef struct {
         CYMessageParameter *messageParameter_;
         CYProtocol *protocol_;
         CYSelectorPart *selector_;
-        CYTypeModifier *modifier_;
-        CYTypedIdentifier *typedIdentifier_;
-        CYTypedParameter *typedParameter_;
 @end
 
 @begin E4X
@@ -426,6 +429,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <member_> MemberAccess
 %type <expression_> MemberExpression_
 %type <expression_> MemberExpression
+%type <module_> Module
 %type <expression_> MultiplicativeExpression
 %type <expression_> NewExpression
 %type <null_> NullLiteral
@@ -472,8 +476,26 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <word_> WordOpt
 %type <expression_> Variable
 
-@begin ObjectiveC
+@begin C
 %type <typedIdentifier_> ArrayedType
+%type <expression_> EncodedType
+%type <modifier_> FunctionedType
+%type <specifier_> IntegerType
+%type <specifier_> IntegerTypeOpt
+%type <typedIdentifier_> PrefixedType
+%type <specifier_> PrimitiveType
+%type <typedIdentifier_> TypeParenthetical
+%type <typedIdentifier_> TypeSignifier
+%type <typedIdentifier_> SuffixedType
+%type <modifier_> TypeQualifierLeft
+%type <typedIdentifier_> TypeQualifierRight
+%type <typedIdentifier_> TypedIdentifier
+%type <typedParameter_> TypedParameterList_
+%type <typedParameter_> TypedParameterList
+%type <typedParameter_> TypedParameterListOpt
+@end
+
+@begin ObjectiveC
 %type <expression_> BoxableExpression
 %type <statement_> CategoryStatement
 %type <expression_> ClassExpression
@@ -488,10 +510,6 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <protocol_> ClassProtocolListOpt
 %type <protocol_> ClassProtocols
 %type <protocol_> ClassProtocolsOpt
-%type <expression_> EncodedType
-%type <modifier_> FunctionedType
-%type <specifier_> IntegerType
-%type <specifier_> IntegerTypeOpt
 %type <expression_> MessageExpression
 %type <messageParameter_> MessageParameter
 %type <messageParameter_> MessageParameters
@@ -499,9 +517,6 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <messageParameter_> MessageParameterListOpt
 %type <bool_> MessageScope
 %type <typedIdentifier_> ModifiedType
-%type <module_> Module
-%type <typedIdentifier_> PrefixedType
-%type <specifier_> PrimitiveType
 %type <argument_> SelectorCall_
 %type <argument_> SelectorCall
 %type <selector_> SelectorExpression_
@@ -509,16 +524,7 @@ int cylex(YYSTYPE *, cy::location *, void *);
 %type <selector_> SelectorExpressionOpt
 %type <argument_> SelectorList
 %type <word_> SelectorWordOpt
-%type <typedIdentifier_> SuffixedType
 %type <expression_> TypeOpt
-%type <typedIdentifier_> TypeParenthetical
-%type <modifier_> TypeQualifierLeft
-%type <typedIdentifier_> TypeQualifierRight
-%type <typedIdentifier_> TypeSignifier
-%type <typedIdentifier_> TypedIdentifier
-%type <typedParameter_> TypedParameterList_
-%type <typedParameter_> TypedParameterList
-%type <typedParameter_> TypedParameterListOpt
 %type <argument_> VariadicCall
 @end
 
@@ -705,6 +711,8 @@ Identifier
     | "typedef" { $$ = $1; }
     | "unsigned" { $$ = $1; }
     | "signed" { $$ = $1; }
+@end
+@begin ObjectiveC
     | "YES" { $$ = $1; }
     | "NO" { $$ = $1; }
 @end
@@ -1394,8 +1402,8 @@ ProgramBodyOpt
     ;
 /* }}} */
 
-@begin ObjectiveC
-/* Cycript (Objective-C): Type Encoding {{{ */
+@begin C
+/* Cycript (C): Type Encoding {{{ */
 TypeParenthetical
     : "(" LexPushInOff PrefixedType ")" LexPopIn { $$ = $3; }
     ;
@@ -1473,6 +1481,9 @@ PrimaryExpression
     : "@encode" "(" EncodedType ")" { $$ = $3; }
     ;
 /* }}} */
+@end
+
+@begin ObjectiveC
 /* Cycript (Objective-C): @class Declaration {{{ */
 ClassSuperOpt
     /* XXX: why the hell did I choose MemberExpression? */
@@ -1626,7 +1637,9 @@ PrimaryExpression
     | "@selector" "(" LexPushInOff SelectorExpression ")" LexPopIn { $$ = CYNew CYSelector($4); }
     ;
 /* }}} */
-/* Cycript (Objective-C): @import Directive {{{ */
+@end
+
+/* Cycript: @import Directive {{{ */
 Module
     : Module "." Word { $$ = CYNew CYModule($3, $1); }
     | Word { $$ = CYNew CYModule($1); }
@@ -1636,6 +1649,8 @@ Declaration__
     : "@import" Module { $$ = CYNew CYImport($2); }
     ;
 /* }}} */
+
+@begin ObjectiveC
 /* Cycript (Objective-C): Boxed Expressions {{{ */
 BoxableExpression
     : NullLiteral { $$ = $1; }
index d67971fa241dcefe81d8ab3235c3323a9ab40d02..203a432992fe9b448f3a591754b743b3d6591577 100644 (file)
@@ -77,10 +77,6 @@ void CYClassStatement::Output(CYOutput &out, CYFlags flags) const {
 void CYField::Output(CYOutput &out) const {
 }
 
-void CYImport::Output(CYOutput &out, CYFlags flags) const {
-    out << "@import";
-}
-
 void CYInstanceLiteral::Output(CYOutput &out, CYFlags flags) const {
     out << '#';
     number_->Output(out, CYRight(flags));
@@ -99,12 +95,6 @@ void CYMessage::Output(CYOutput &out, bool replace) const {
     out << code_;
 }
 
-void CYModule::Output(CYOutput &out) const {
-    out << part_;
-    if (next_ != NULL)
-        out << '.' << next_;
-}
-
 void CYBox::Output(CYOutput &out, CYFlags flags) const {
     out << '@';
     value_->Output(out, Precedence(), CYRight(flags));
index 1502aa22c09abf3224fd436546f4bb0db2097376..9de4c093d72db6995c4cf5ab8c8da591f430817a 100644 (file)
@@ -92,10 +92,6 @@ CYStatement *CYField::Replace(CYContext &context) const { $T(NULL)
     );
 }
 
-CYStatement *CYImport::Replace(CYContext &context) {
-    return $ CYVar($L1($L(module_->part_->Word(), $C1($V("require"), module_->Replace(context, "/")))));
-}
-
 CYExpression *CYInstanceLiteral::Replace(CYContext &context) {
     return $N1($V("Instance"), number_);
 }
@@ -146,12 +142,6 @@ CYExpression *CYMessageParameter::TypeSignature(CYContext &context) const {
     return MessageType(context, type_, next_);
 }
 
-CYString *CYModule::Replace(CYContext &context, const char *separator) const {
-    if (next_ == NULL)
-        return $ CYString(part_);
-    return $ CYString($pool.strcat(next_->Replace(context, separator)->Value(), separator, part_->Word(), NULL));
-}
-
 CYExpression *CYBox::Replace(CYContext &context) {
     return $C1($M($V("Instance"), $S("box")), value_);
 }
index e04f71d38a8732675685ee199c4ce4184f65413b..7578d7e8bddfefc8297d2ef0620cbd9e92461ddb 100644 (file)
@@ -183,36 +183,6 @@ struct CYProtocol :
     void Output(CYOutput &out) const;
 };
 
-struct CYModule :
-    CYNext<CYModule>,
-    CYThing
-{
-    CYWord *part_;
-
-    CYModule(CYWord *part, CYModule *next = NULL) :
-        CYNext<CYModule>(next),
-        part_(part)
-    {
-    }
-
-    CYString *Replace(CYContext &context, const char *separator) const;
-    void Output(CYOutput &out) const;
-};
-
-struct CYImport :
-    CYStatement
-{
-    CYModule *module_;
-
-    CYImport(CYModule *module) :
-        module_(module)
-    {
-    }
-
-    virtual CYStatement *Replace(CYContext &context);
-    virtual void Output(CYOutput &out, CYFlags flags) const;
-};
-
 struct CYClass {
     CYClassName *name_;
     CYExpression *super_;
index 3794c498856b3bda78ea26562f9934d6c2aaf386..778acb5d0c3557486380fc328d1adafecdf3cb57 100644 (file)
@@ -440,6 +440,10 @@ void CYIfComprehension::Output(CYOutput &out) const {
     out << "if" << ' ' << '(' << *test_ << ')' << next_;
 }
 
+void CYImport::Output(CYOutput &out, CYFlags flags) const {
+    out << "@import";
+}
+
 void CYIndirectMember::Output(CYOutput &out, CYFlags flags) const {
     object_->Output(out, Precedence(), CYLeft(flags));
     if (const char *word = property_->Word())
@@ -547,6 +551,12 @@ void CYLetStatement::Output(CYOutput &out, CYFlags flags) const {
     code_->Single(out, CYRight(flags));
 }
 
+void CYModule::Output(CYOutput &out) const {
+    out << part_;
+    if (next_ != NULL)
+        out << '.' << next_;
+}
+
 namespace cy {
 namespace Syntax {
 
index fab18af4d6c3f6d09ed7494a5683f10fe447de3b..c7894ce7e46b6d5277ec895a7354d5d824c6a4c7 100644 (file)
@@ -1851,6 +1851,36 @@ struct CYLambda :
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
+struct CYModule :
+    CYNext<CYModule>,
+    CYThing
+{
+    CYWord *part_;
+
+    CYModule(CYWord *part, CYModule *next = NULL) :
+        CYNext<CYModule>(next),
+        part_(part)
+    {
+    }
+
+    CYString *Replace(CYContext &context, const char *separator) const;
+    void Output(CYOutput &out) const;
+};
+
+struct CYImport :
+    CYStatement
+{
+    CYModule *module_;
+
+    CYImport(CYModule *module) :
+        module_(module)
+    {
+    }
+
+    virtual CYStatement *Replace(CYContext &context);
+    virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
 struct CYTypeDefinition :
     CYStatement
 {
index b658cf733e994a20b909eb5c75a48cf83483dede..1cb020c209721108114be992636768eff73fa841 100644 (file)
@@ -507,6 +507,10 @@ CYStatement *CYIfComprehension::Replace(CYContext &context, CYStatement *stateme
     return $ CYIf(test_, CYComprehension::Replace(context, statement));
 }
 
+CYStatement *CYImport::Replace(CYContext &context) {
+    return $ CYVar($L1($L(module_->part_->Word(), $C1($V("require"), module_->Replace(context, "/")))));
+}
+
 CYExpression *CYIndirect::Replace(CYContext &context) {
     return $M(rhs_, $S("$cyi"));
 }
@@ -534,6 +538,12 @@ CYStatement *CYLetStatement::Replace(CYContext &context) {
     return $E($ CYCall(CYNonLocalize(context, $ CYFunctionExpression(NULL, declarations_->Parameter(context), code_)), declarations_->Argument(context)));
 }
 
+CYString *CYModule::Replace(CYContext &context, const char *separator) const {
+    if (next_ == NULL)
+        return $ CYString(part_);
+    return $ CYString($pool.strcat(next_->Replace(context, separator)->Value(), separator, part_->Word(), NULL));
+}
+
 CYExpression *CYMultiply::Replace(CYContext &context) {
     CYInfix::Replace(context);