|
@@ -15,6 +15,9 @@ namespace zp
|
|
struct UnionBlock;
|
|
struct UnionBlock;
|
|
struct Loop;
|
|
struct Loop;
|
|
|
|
|
|
|
|
+ // forward declaration
|
|
|
|
+ class AstVisitor;
|
|
|
|
+
|
|
class Parser;
|
|
class Parser;
|
|
class ParserException;
|
|
class ParserException;
|
|
}
|
|
}
|
|
@@ -34,6 +37,8 @@ enum class zp::Instruction : char
|
|
struct zp::Block
|
|
struct zp::Block
|
|
{
|
|
{
|
|
virtual ~Block(void) = default;
|
|
virtual ~Block(void) = default;
|
|
|
|
+
|
|
|
|
+ virtual void accept(AstVisitor& v) = 0;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -44,6 +49,8 @@ struct zp::InstructionBlock :
|
|
|
|
|
|
inline void addInstruction(Instruction i) { instructions.push_back(i); }
|
|
inline void addInstruction(Instruction i) { instructions.push_back(i); }
|
|
inline bool isEmpty(void) const { return instructions.empty(); }
|
|
inline bool isEmpty(void) const { return instructions.empty(); }
|
|
|
|
+
|
|
|
|
+ void accept(AstVisitor& v);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -52,12 +59,15 @@ struct zp::UnionBlock :
|
|
{
|
|
{
|
|
std::vector<std::unique_ptr<Block>> instructions;
|
|
std::vector<std::unique_ptr<Block>> instructions;
|
|
inline void addBlock(std::unique_ptr<Block>&& block) { instructions.push_back(std::move(block)); }
|
|
inline void addBlock(std::unique_ptr<Block>&& block) { instructions.push_back(std::move(block)); }
|
|
|
|
+
|
|
|
|
+ void accept(AstVisitor& v);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
struct zp::Loop :
|
|
struct zp::Loop :
|
|
public UnionBlock
|
|
public UnionBlock
|
|
{
|
|
{
|
|
|
|
+ void accept(AstVisitor& v);
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|