diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-16 22:52:40 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-16 22:52:40 +0000 |
commit | 392805699c8d411400901b8e3d7298f0f9198bb5 (patch) | |
tree | 2d724780d9e787d7e17211ce6181d395aae1fcaf /c_parser/include | |
parent | 24d1547515ddeb03c6fcf7ae0162b0c397180a40 (diff) | |
download | Compiler-392805699c8d411400901b8e3d7298f0f9198bb5.tar.gz Compiler-392805699c8d411400901b8e3d7298f0f9198bb5.zip |
Changing ast and improving it
Diffstat (limited to 'c_parser/include')
-rw-r--r-- | c_parser/include/ast_declaration.hpp | 18 | ||||
-rw-r--r-- | c_parser/include/ast_primitives.hpp | 19 |
2 files changed, 31 insertions, 6 deletions
diff --git a/c_parser/include/ast_declaration.hpp b/c_parser/include/ast_declaration.hpp index e529378..98fe255 100644 --- a/c_parser/include/ast_declaration.hpp +++ b/c_parser/include/ast_declaration.hpp @@ -5,15 +5,21 @@ class ast_Declaration : public ast_Base { private: - const std::string id; -protected: +public: + virtual void print() const override = 0; +}; + +class ast_VariableDeclaration : public ast_Declartaion { +private: + const std::string id; + const std::string type; public: - ast_Declaration(const std::string _id) : id(_id) {} - virtual void print() const override { - std::cout << id; - } + ast_VariableDeclaration(const std::string& _id, const std::string& _type) : + id(_id), type(_type) {} + + virtual void print() const override {} }; #endif diff --git a/c_parser/include/ast_primitives.hpp b/c_parser/include/ast_primitives.hpp new file mode 100644 index 0000000..fbcb1b4 --- /dev/null +++ b/c_parser/include/ast_primitives.hpp @@ -0,0 +1,19 @@ +#ifndef AST_PRIMITIVES_HPP +#define AST_PRIMITIVES_HPP + +#include "ast.hpp" + +#include <string> + +class ast_Variable : public ast_Base { +private: + std::string id; +public: + ast_Variable(const std::string& _id) : id(_id) {} + + virtual void print() const override { + std::cout << "<Variable id=\"" << id << "\" />" << std::endl; + } +}; + +#endif |