]> git.saurik.com Git - cycript.git/blobdiff - Parser.hpp
Added a CYOutput object between std::ostream and the actual mechanism.
[cycript.git] / Parser.hpp
index 9daf63e993535a3af09ebcf4e43d681abd2c0c29..cab829ab5b69b710f9507e3afc5724a0d60502d0 100644 (file)
@@ -1,3 +1,42 @@
+/* Cycript - Remove Execution Server and Disassembler
+ * Copyright (C) 2009  Jay Freeman (saurik)
+*/
+
+/* Modified BSD License {{{ */
+/*
+ *        Redistribution and use in source and binary
+ * forms, with or without modification, are permitted
+ * provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the
+ *    above copyright notice, this list of conditions
+ *    and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the
+ *    above copyright notice, this list of conditions
+ *    and the following disclaimer in the documentation
+ *    and/or other materials provided with the
+ *    distribution.
+ * 3. The name of the author may not be used to endorse
+ *    or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/* }}} */
+
 #ifndef CYPARSER_HPP
 #define CYPARSER_HPP
 
@@ -28,30 +67,58 @@ struct CYNext {
 };
 
 struct CYThing {
-    virtual void Output(std::ostream &out) const = 0;
+    virtual void Output(struct CYOutput &out) const = 0;
 };
 
-_finline std::ostream &operator <<(std::ostream &out, const CYThing &rhs) {
-    rhs.Output(out);
-    return out;
-}
+struct CYOutput {
+    std::ostream &out_;
+
+    CYOutput(std::ostream &out) :
+        out_(out)
+    {
+    }
+
+    _finline CYOutput &operator <<(char rhs) {
+        out_ << rhs;
+        return *this;
+    }
+
+    _finline CYOutput &operator <<(const char *rhs) {
+        out_ << rhs;
+        return *this;
+    }
+
+    _finline CYOutput &operator <<(const CYThing &rhs) {
+        rhs.Output(*this);
+        return *this;
+    }
+};
 
 struct CYSource :
     CYNext<CYSource>
 {
-    virtual void Show(std::ostream &out) const;
-    virtual void Output(std::ostream &out) const = 0;
-    virtual void Output(std::ostream &out, bool block) const;
+    virtual bool IsBlock() const {
+        return next_ != NULL;
+    }
+
+    virtual void Show(CYOutput &out) const;
+    virtual void Output(CYOutput &out) const = 0;
+    virtual void Output(CYOutput &out, bool block) const;
+    virtual void Output_(CYOutput &out) const;
 };
 
-struct CYName :
-    CYThing
-{
-    virtual const char *Name() const = 0;
+struct CYPropertyName {
+    virtual void PropertyName(CYOutput &out) const = 0;
+};
+
+struct CYClassName {
+    virtual void ClassName(CYOutput &out, bool object) const = 0;
 };
 
 struct CYWord :
-    CYName
+    CYThing,
+    CYPropertyName,
+    CYClassName
 {
     const char *word_;
 
@@ -64,13 +131,16 @@ struct CYWord :
         return word_;
     }
 
-    virtual const char *Name() const {
-        return Value();
-    }
+    virtual void Output(CYOutput &out) const;
 
-    virtual void Output(std::ostream &out) const;
+    virtual void ClassName(CYOutput &out, bool object) const;
+    virtual void PropertyName(CYOutput &out) const;
 };
 
+_finline std::ostream &operator <<(std::ostream &lhs, const CYWord &rhs) {
+    return lhs << rhs.Value();
+}
+
 struct CYIdentifier :
     CYWord
 {
@@ -83,11 +153,11 @@ struct CYIdentifier :
 struct CYLabel :
     CYNext<CYLabel>
 {
-    CYIdentifier *identifier_;
+    CYIdentifier *name_;
 
-    CYLabel(CYIdentifier *identifier, CYLabel *next) :
+    CYLabel(CYIdentifier *name, CYLabel *next) :
         CYNext<CYLabel>(next),
-        identifier_(identifier)
+        name_(name)
     {
     }
 };
@@ -95,11 +165,35 @@ struct CYLabel :
 struct CYStatement :
     CYSource
 {
-    CYLabel *label_;
+    CYLabel *labels_;
+
+    CYStatement() :
+        labels_(NULL)
+    {
+    }
 
     void AddLabel(CYIdentifier *identifier) {
-        label_ = new CYLabel(identifier, label_);
+        labels_ = new CYLabel(identifier, labels_);
+    }
+
+    virtual void Output_(CYOutput &out) const;
+};
+
+struct CYBlock :
+    CYStatement
+{
+    CYStatement *statements_;
+
+    CYBlock(CYStatement *statements) :
+        statements_(statements)
+    {
+    }
+
+    virtual bool IsBlock() const {
+        return true;
     }
+
+    virtual void Output(CYOutput &out) const;
 };
 
 enum CYState {
@@ -117,6 +211,7 @@ class CYDriver {
 
     const char *data_;
     size_t size_;
+    FILE *file_;
 
     std::string filename_;
 
@@ -139,38 +234,45 @@ class CYDriver {
     ~CYDriver();
 };
 
-struct CYPart {
-    virtual void Part(std::ostream &out) const = 0;
-};
-
-struct CYForInitialiser :
-    CYPart
-{
+enum CYFlags {
+    CYNoFlags =    0,
+    CYNoBrace =    (1 << 0),
+    CYNoFunction = (1 << 1),
+    CYNoLeader =   (1 << 2),
+    CYNoTrailer =  (1 << 3),
+    CYNoIn =       (1 << 4),
+    CYNoHyphen =   (1 << 5),
+    CYNoBF =       (CYNoBrace | CYNoFunction),
 };
 
-struct CYForInInitialiser :
-    CYPart
-{
+struct CYForInitialiser {
+    virtual void For(CYOutput &out) const = 0;
 };
 
-enum CYFlags {
-    CYNoFlags,
-    CYNoBrace,
-    CYNoFunction,
-    CYNoLeader,
-    CYNoTrailer,
-    CYNoIn
+struct CYForInInitialiser {
+    virtual void ForIn(CYOutput &out, CYFlags flags) const = 0;
+    virtual const char *ForEachIn() const = 0;
+    virtual void ForEachIn(CYOutput &out) const = 0;
 };
 
 struct CYExpression :
     CYNext<CYExpression>,
     CYForInitialiser,
-    CYForInInitialiser
+    CYForInInitialiser,
+    CYClassName
 {
     virtual unsigned Precedence() const = 0;
-    virtual void Part(std::ostream &out) const;
-    virtual void Output(std::ostream &out, CYFlags flags) const = 0;
-    void Output(std::ostream &out, unsigned precedence, CYFlags flags) const;
+
+    virtual void For(CYOutput &out) const;
+    virtual void ForIn(CYOutput &out, CYFlags flags) const;
+
+    virtual const char *ForEachIn() const;
+    virtual void ForEachIn(CYOutput &out) const;
+
+    virtual void Output(CYOutput &out, CYFlags flags) const = 0;
+    void Output(CYOutput &out, unsigned precedence, CYFlags flags) const;
+
+    virtual void ClassName(CYOutput &out, bool object) const;
 
     virtual const char *Word() const {
         return NULL;
@@ -207,7 +309,92 @@ struct CYCompound :
 
     CYPrecedence(17)
 
-    void Output(std::ostream &out, CYFlags flags) const;
+    void Output(CYOutput &out, CYFlags flags) const;
+};
+
+struct CYComprehension :
+    CYNext<CYComprehension>
+{
+    void Output(CYOutput &out) const;
+    virtual const char *Name() const = 0;
+
+    virtual void Begin_(CYOutput &out) const = 0;
+
+    virtual void End_(CYOutput &out) const {
+    }
+};
+
+struct CYForInComprehension :
+    CYComprehension
+{
+    CYIdentifier *name_;
+    CYExpression *set_;
+
+    CYForInComprehension(CYIdentifier *name, CYExpression *set) :
+        name_(name),
+        set_(set)
+    {
+    }
+
+    virtual const char *Name() const {
+        return name_->Value();
+    }
+
+    virtual void Begin_(CYOutput &out) const;
+};
+
+struct CYForEachInComprehension :
+    CYComprehension
+{
+    CYIdentifier *name_;
+    CYExpression *set_;
+
+    CYForEachInComprehension(CYIdentifier *name, CYExpression *set) :
+        name_(name),
+        set_(set)
+    {
+    }
+
+    virtual const char *Name() const {
+        return name_->Value();
+    }
+
+    virtual void Begin_(CYOutput &out) const;
+    virtual void End_(CYOutput &out) const;
+};
+
+struct CYIfComprehension :
+    CYComprehension
+{
+    CYExpression *test_;
+
+    CYIfComprehension(CYExpression *test) :
+        test_(test)
+    {
+    }
+
+    virtual const char *Name() const {
+        return NULL;
+    }
+
+    virtual void Begin_(CYOutput &out) const;
+};
+
+struct CYArrayComprehension :
+    CYExpression
+{
+    CYExpression *expression_;
+    CYComprehension *comprehensions_;
+
+    CYArrayComprehension(CYExpression *expression, CYComprehension *comprehensions) :
+        expression_(expression),
+        comprehensions_(comprehensions)
+    {
+    }
+
+    CYPrecedence(0)
+
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYLiteral :
@@ -216,6 +403,12 @@ struct CYLiteral :
     CYPrecedence(0)
 };
 
+struct CYMagic :
+    CYExpression
+{
+    CYPrecedence(0)
+};
+
 struct CYSelectorPart :
     CYNext<CYSelectorPart>
 {
@@ -229,7 +422,7 @@ struct CYSelectorPart :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYSelector :
@@ -244,7 +437,7 @@ struct CYSelector :
 
     CYPrecedence(1)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYRange {
@@ -267,12 +460,13 @@ struct CYRange {
     }
 };
 
+extern CYRange DigitRange_;
 extern CYRange WordStartRange_;
 extern CYRange WordEndRange_;
 
 struct CYString :
     CYLiteral,
-    CYName
+    CYPropertyName
 {
     const char *value_;
     size_t size_;
@@ -293,10 +487,6 @@ struct CYString :
         return value_;
     }
 
-    virtual const char *Name() const {
-        return Value();
-    }
-
     virtual const char *Word() const {
         if (size_ == 0 || !WordStartRange_[value_[0]])
             return NULL;
@@ -306,16 +496,17 @@ struct CYString :
         return Value();
     }
 
-    virtual void Output(std::ostream &out) const {
+    virtual void Output(CYOutput &out) const {
         return Output(out, CYNoFlags);
     }
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
+    virtual void PropertyName(CYOutput &out) const;
 };
 
 struct CYNumber :
     CYLiteral,
-    CYName
+    CYPropertyName
 {
     double value_;
 
@@ -328,15 +519,12 @@ struct CYNumber :
         return value_;
     }
 
-    virtual const char *Name() const {
-        throw;
-    }
-
-    virtual void Output(std::ostream &out) const {
+    virtual void Output(CYOutput &out) const {
         return Output(out, CYNoFlags);
     }
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
+    virtual void PropertyName(CYOutput &out) const;
 };
 
 struct CYNull :
@@ -348,28 +536,26 @@ struct CYNull :
     {
     }
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYThis :
     CYWord,
-    CYExpression
+    CYMagic
 {
     CYThis() :
         CYWord("this")
     {
     }
 
-    CYPrecedence(0)
-
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYBoolean :
     CYLiteral
 {
     virtual bool Value() const = 0;
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYFalse :
@@ -408,7 +594,7 @@ struct CYVariable :
 
     CYPrecedence(0)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYPrefix :
@@ -424,7 +610,7 @@ struct CYPrefix :
     virtual bool Alphabetic() const = 0;
     virtual const char *Operator() const = 0;
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYInfix :
@@ -439,10 +625,14 @@ struct CYInfix :
     {
     }
 
+    void SetLeft(CYExpression *lhs) {
+        lhs_ = lhs;
+    }
+
     virtual bool Alphabetic() const = 0;
     virtual const char *Operator() const = 0;
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYPostfix :
@@ -457,7 +647,7 @@ struct CYPostfix :
 
     virtual const char *Operator() const = 0;
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYAssignment :
@@ -472,9 +662,13 @@ struct CYAssignment :
     {
     }
 
+    void SetLeft(CYExpression *lhs) {
+        lhs_ = lhs;
+    }
+
     virtual const char *Operator() const = 0;
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYArgument :
@@ -490,7 +684,7 @@ struct CYArgument :
     {
     }
 
-    void Output(std::ostream &out) const;
+    void Output(CYOutput &out) const;
 };
 
 struct CYBlank :
@@ -515,7 +709,7 @@ struct CYClause :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYElement :
@@ -529,7 +723,7 @@ struct CYElement :
     {
     }
 
-    void Output(std::ostream &out) const;
+    void Output(CYOutput &out) const;
 };
 
 struct CYArray :
@@ -542,11 +736,10 @@ struct CYArray :
     {
     }
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYDeclaration :
-    CYThing,
     CYForInInitialiser
 {
     CYIdentifier *identifier_;
@@ -558,31 +751,62 @@ struct CYDeclaration :
     {
     }
 
-    virtual void Part(std::ostream &out) const;
-    virtual void Output(std::ostream &out) const;
+    virtual void ForIn(CYOutput &out, CYFlags flags) const;
+
+    virtual const char *ForEachIn() const;
+    virtual void ForEachIn(CYOutput &out) const;
+
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYDeclarations :
-    CYStatement,
+    CYNext<CYDeclarations>,
     CYForInitialiser
 {
     CYDeclaration *declaration_;
-    CYDeclarations *next_;
 
     CYDeclarations(CYDeclaration *declaration, CYDeclarations *next) :
-        declaration_(declaration),
-        next_(next)
+        CYNext<CYDeclarations>(next),
+        declaration_(declaration)
+    {
+    }
+
+    virtual void For(CYOutput &out) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
+struct CYVar :
+    CYStatement
+{
+    CYDeclarations *declarations_;
+
+    CYVar(CYDeclarations *declarations) :
+        declarations_(declarations)
     {
     }
 
-    virtual void Part(std::ostream &out) const;
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
+};
+
+struct CYLet :
+    CYStatement
+{
+    CYDeclarations *declarations_;
+    CYStatement *statements_;
+
+    CYLet(CYDeclarations *declarations, CYStatement *statements) :
+        declarations_(declarations),
+        statements_(statements)
+    {
+    }
+
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYField :
     CYNext<CYField>
 {
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYMessageParameter :
@@ -601,7 +825,7 @@ struct CYMessageParameter :
 };
 
 struct CYMessage :
-    CYSource
+    CYNext<CYMessage>
 {
     bool instance_;
     CYExpression *type_;
@@ -616,18 +840,19 @@ struct CYMessage :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out, bool replace) const;
 };
 
 struct CYClass :
-    CYSource
+    CYExpression,
+    CYStatement
 {
-    CYIdentifier *name_;
+    CYClassName *name_;
     CYExpression *super_;
     CYField *fields_;
     CYMessage *messages_;
 
-    CYClass(CYIdentifier *name, CYExpression *super, CYField *fields, CYMessage *messages) :
+    CYClass(CYClassName *name, CYExpression *super, CYField *fields, CYMessage *messages) :
         name_(name),
         super_(super),
         fields_(fields),
@@ -635,7 +860,25 @@ struct CYClass :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    CYPrecedence(0)
+
+    virtual void Output(CYOutput &out) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
+struct CYCategory :
+    CYStatement
+{
+    CYClassName *name_;
+    CYMessage *messages_;
+
+    CYCategory(CYClassName *name, CYMessage *messages) :
+        name_(name),
+        messages_(messages)
+    {
+    }
+
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYFunctionParameter :
@@ -650,7 +893,7 @@ struct CYFunctionParameter :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYFor :
@@ -669,7 +912,7 @@ struct CYFor :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYForIn :
@@ -686,23 +929,40 @@ struct CYForIn :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
+};
+
+struct CYForEachIn :
+    CYStatement
+{
+    CYForInInitialiser *initialiser_;
+    CYExpression *set_;
+    CYStatement *code_;
+
+    CYForEachIn(CYForInInitialiser *initialiser, CYExpression *set, CYStatement *code) :
+        initialiser_(initialiser),
+        set_(set),
+        code_(code)
+    {
+    }
+
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYProperty :
     CYNext<CYProperty>
 {
-    CYName *name_;
+    CYPropertyName *name_;
     CYExpression *value_;
 
-    CYProperty(CYName *name, CYExpression *value, CYProperty *next) :
+    CYProperty(CYPropertyName *name, CYExpression *value, CYProperty *next) :
         CYNext<CYProperty>(next),
         name_(name),
         value_(value)
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYObject :
@@ -715,7 +975,7 @@ struct CYObject :
     {
     }
 
-    void Output(std::ostream &out, CYFlags flags) const;
+    void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYCatch :
@@ -730,7 +990,7 @@ struct CYCatch :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYSend :
@@ -747,7 +1007,7 @@ struct CYSend :
 
     CYPrecedence(0)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYMember :
@@ -762,9 +1022,35 @@ struct CYMember :
     {
     }
 
+    void SetLeft(CYExpression *object) {
+        object_ = object;
+    }
+};
+
+struct CYDirectMember :
+    CYMember
+{
+    CYDirectMember(CYExpression *object, CYExpression *property) :
+        CYMember(object, property)
+    {
+    }
+
+    CYPrecedence(1)
+
+    virtual void Output(CYOutput &out, CYFlags flags) const;
+};
+
+struct CYIndirectMember :
+    CYMember
+{
+    CYIndirectMember(CYExpression *object, CYExpression *property) :
+        CYMember(object, property)
+    {
+    }
+
     CYPrecedence(1)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYNew :
@@ -781,7 +1067,7 @@ struct CYNew :
 
     CYPrecedence(1)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYCall :
@@ -798,7 +1084,7 @@ struct CYCall :
 
     CYPrecedence(2)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYIf :
@@ -815,7 +1101,7 @@ struct CYIf :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYDoWhile :
@@ -830,7 +1116,7 @@ struct CYDoWhile :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYWhile :
@@ -845,7 +1131,7 @@ struct CYWhile :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYLambda :
@@ -864,7 +1150,7 @@ struct CYLambda :
 
     CYPrecedence(0)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYFunction :
@@ -876,7 +1162,7 @@ struct CYFunction :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYExpress :
@@ -889,7 +1175,7 @@ struct CYExpress :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYContinue :
@@ -902,7 +1188,7 @@ struct CYContinue :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYBreak :
@@ -915,7 +1201,7 @@ struct CYBreak :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYReturn :
@@ -928,14 +1214,14 @@ struct CYReturn :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYEmpty :
     CYStatement
 {
-    virtual void Output(std::ostream &out) const;
-    virtual void Output(std::ostream &out, bool block) const;
+    virtual void Output(CYOutput &out) const;
+    virtual void Output(CYOutput &out, bool block) const;
 };
 
 struct CYTry :
@@ -952,7 +1238,7 @@ struct CYTry :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYThrow :
@@ -965,7 +1251,7 @@ struct CYThrow :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYWith :
@@ -980,7 +1266,7 @@ struct CYWith :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYSwitch :
@@ -995,7 +1281,7 @@ struct CYSwitch :
     {
     }
 
-    virtual void Output(std::ostream &out) const;
+    virtual void Output(CYOutput &out) const;
 };
 
 struct CYCondition :
@@ -1014,7 +1300,7 @@ struct CYCondition :
 
     CYPrecedence(15)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYAddressOf :
@@ -1032,7 +1318,7 @@ struct CYAddressOf :
     CYAlphabetic(false)
     CYPrecedence(2)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 struct CYIndirect :
@@ -1050,7 +1336,7 @@ struct CYIndirect :
     CYAlphabetic(false)
     CYPrecedence(1)
 
-    virtual void Output(std::ostream &out, CYFlags flags) const;
+    virtual void Output(CYOutput &out, CYFlags flags) const;
 };
 
 #define CYPostfix_(op, name) \