]> git.saurik.com Git - cycript.git/blobdiff - Syntax.hpp
Verify lexer tokens are always default reductions.
[cycript.git] / Syntax.hpp
index 786b9f72969c116d35b8b7e830500927e4feefd8..f11c2f29b8632c5363e28d176ed3d358492aa2ca 100644 (file)
@@ -199,6 +199,13 @@ struct CYStatement :
 
 typedef CYList<CYStatement> CYStatements;
 
+struct CYForInitializer :
+    CYStatement
+{
+    virtual CYForInitializer *Replace(CYContext &context) = 0;
+    virtual void Output(CYOutput &out, CYFlags flags) const = 0;
+};
+
 struct CYWord :
     CYThing,
     CYPropertyName
@@ -452,11 +459,6 @@ struct CYBlock :
     virtual CYStatement *Return();
 };
 
-struct CYForInitializer {
-    virtual CYExpression *Replace(CYContext &context) = 0;
-    virtual void Output(CYOutput &out, CYFlags flags) const = 0;
-};
-
 struct CYTarget;
 struct CYVar;
 
@@ -473,7 +475,6 @@ struct CYNumber;
 struct CYString;
 
 struct CYExpression :
-    CYForInitializer,
     CYThing
 {
     virtual int Precedence() const = 0;
@@ -895,6 +896,12 @@ struct CYThis :
 struct CYBoolean :
     CYTrivial
 {
+    CYPrecedence(4)
+
+    virtual bool RightHand() const {
+        return true;
+    }
+
     virtual bool Value() const = 0;
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
@@ -1020,8 +1027,8 @@ struct CYAssignment :
     {
     }
 
-    void SetLeft(CYTarget *lhs) {
-        lhs_ = lhs;
+    void SetRight(CYExpression *rhs) {
+        rhs_ = rhs;
     }
 
     virtual const char *Operator() const = 0;
@@ -1205,22 +1212,8 @@ struct CYDeclarations :
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
-struct CYForDeclarations :
-    CYForInitializer
-{
-    CYDeclarations *declarations_;
-
-    CYForDeclarations(CYDeclarations *declarations) :
-        declarations_(declarations)
-    {
-    }
-
-    virtual CYExpression *Replace(CYContext &context);
-    virtual void Output(CYOutput &out, CYFlags flags) const;
-};
-
 struct CYVar :
-    CYStatement
+    CYForInitializer
 {
     CYDeclarations *declarations_;
 
@@ -1231,12 +1224,12 @@ struct CYVar :
 
     CYCompact(None)
 
-    virtual CYStatement *Replace(CYContext &context);
+    virtual CYForInitializer *Replace(CYContext &context);
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYLet :
-    CYStatement
+    CYForInitializer
 {
     bool constant_;
     CYDeclarations *declarations_;
@@ -1249,7 +1242,7 @@ struct CYLet :
 
     CYCompact(None)
 
-    virtual CYStatement *Replace(CYContext &context);
+    virtual CYForInitializer *Replace(CYContext &context);
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
@@ -1274,6 +1267,8 @@ struct CYProperty :
     {
     }
 
+    virtual bool Update() const;
+
     CYProperty *ReplaceAll(CYContext &context, CYBuilder &builder, CYExpression *self, bool update);
     void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, bool protect);
 
@@ -1341,6 +1336,26 @@ struct CYForIn :
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
+struct CYForInitialized :
+    CYStatement
+{
+    CYDeclaration *declaration_;
+    CYExpression *set_;
+    CYStatement *code_;
+
+    CYForInitialized(CYDeclaration *declaration, CYExpression *set, CYStatement *code) :
+        declaration_(declaration),
+        set_(set),
+        code_(code)
+    {
+    }
+
+    CYCompact(Long)
+
+    virtual CYStatement *Replace(CYContext &context);
+    virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
 struct CYForOf :
     CYStatement
 {
@@ -1708,6 +1723,8 @@ struct CYPropertyMethod :
     {
     }
 
+    bool Update() const override;
+
     virtual CYFunctionExpression *Constructor();
 
     virtual void Replace(CYContext &context, CYBuilder &builder, CYExpression *self, CYExpression *name, bool protect);
@@ -1801,7 +1818,7 @@ struct CYSuperAccess :
 };
 
 struct CYExpress :
-    CYStatement
+    CYForInitializer
 {
     CYExpression *expression_;
 
@@ -1814,7 +1831,7 @@ struct CYExpress :
 
     CYCompact(None)
 
-    CYStatement *Replace(CYContext &context) override;
+    CYForInitializer *Replace(CYContext &context) override;
     virtual void Output(CYOutput &out, CYFlags flags) const;
 
     virtual CYStatement *Return();
@@ -1901,11 +1918,11 @@ struct CYYieldValue :
 };
 
 struct CYEmpty :
-    CYStatement
+    CYForInitializer
 {
     CYCompact(Short)
 
-    virtual CYStatement *Replace(CYContext &context);
+    virtual CYForInitializer *Replace(CYContext &context);
     virtual void Output(CYOutput &out, CYFlags flags) const;
 };