diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-05 20:55:12 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-05 20:55:12 +0000 |
commit | eccb6c5360f213675a513e875bc424b8bdee16e7 (patch) | |
tree | 88b2826a2898223bcd5f02d5e5fd1f2c1c9b7e2a /c_compiler/include/node.hpp | |
parent | 6b7f5137edb18372bc3e3076dab1cb45c8e4c2ec (diff) | |
download | Compiler-eccb6c5360f213675a513e875bc424b8bdee16e7.tar.gz Compiler-eccb6c5360f213675a513e875bc424b8bdee16e7.zip |
Finished ast change and it works
Diffstat (limited to 'c_compiler/include/node.hpp')
-rw-r--r-- | c_compiler/include/node.hpp | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/c_compiler/include/node.hpp b/c_compiler/include/node.hpp index 3390d5b..940a948 100644 --- a/c_compiler/include/node.hpp +++ b/c_compiler/include/node.hpp @@ -13,122 +13,5 @@ public: virtual void printasm() const = 0; }; - -class EmptyNode : public Node { -public: - EmptyNode() {} - - virtual void print() const {} - virtual void printxml() const {} - virtual void printasm() const {} -}; - - -class NodeList : public Node { -protected: - mutable std::vector<const Node*> list; - -public: - NodeList(const Node* _var) { - push(_var); - } - - virtual ~NodeList() { - for(auto& var : list) { - delete var; - } - } - - virtual void print() const { - for(auto&& declaration : list) { - declaration->print(); - } - } - - virtual void printxml() const { - for(auto&& declaration : list) { - declaration->printxml(); - } - } - - virtual void printasm() const { - for(auto&& declaration : list) { - declaration->printasm(); - } - } - - virtual void push(const Node* _var) const { - list.push_back(_var); - } -}; - - -class NodeNode : public Node { -protected: - const Node* leftNode; - const Node* rightNode; - -public: - NodeNode(const Node* _left = new EmptyNode, const Node* _right = new EmptyNode) - : leftNode(_left), rightNode(_right) {} - - virtual ~NodeNode() { - delete leftNode; - delete rightNode; - } - - virtual void print() const { - leftNode->print(); - rightNode->print(); - } - - virtual void printxml() const { - leftNode->printxml(); - rightNode->printxml(); - } - - virtual void printasm() const { - leftNode->printasm(); - rightNode->printasm(); - } - - virtual const Node* getLeft() const { - return leftNode; - } - - virtual const Node* getRight() const { - return rightNode; - } -}; - - -class NodePrimitive : public Node { -protected: - std::string id; - const Node* type; - -public: - NodePrimitive(const std::string& _id = "", const Node* _type = new EmptyNode) - : id(_id), type(_type) {} - - virtual ~NodePrimitive() { - delete type; - } - - virtual void print() const {} - virtual void printxml() const {} - virtual void printasm() const {} -}; - - -class NodeType : public Node { -public: - NodeType() {} - - virtual void print() const {} - virtual void printxml() const {} - virtual void printasm() const {} -}; - #endif |