diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-17 15:44:46 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-17 15:44:46 +0000 |
commit | 31262fce1956cc68503cc6ee52c07bd087fae60e (patch) | |
tree | f2e779a6ed0f0879875e5a0482f2dfcafeaffef3 /c_parser/include/ast_declaration.hpp | |
parent | 045b421e10c3a1d5c96e26d64f35969e11fb3cf5 (diff) | |
parent | b81f60d8b523260526af15361d4ce0ac4a7757c8 (diff) | |
download | Compiler-31262fce1956cc68503cc6ee52c07bd087fae60e.tar.gz Compiler-31262fce1956cc68503cc6ee52c07bd087fae60e.zip |
Merge branch 'parser'
Diffstat (limited to 'c_parser/include/ast_declaration.hpp')
-rw-r--r-- | c_parser/include/ast_declaration.hpp | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/c_parser/include/ast_declaration.hpp b/c_parser/include/ast_declaration.hpp index e529378..01b1498 100644 --- a/c_parser/include/ast_declaration.hpp +++ b/c_parser/include/ast_declaration.hpp @@ -3,16 +3,34 @@ #include "ast.hpp" +#include <vector> + +// Declaration that holds a list of declarations + class ast_Declaration : public ast_Base { private: - const std::string id; -protected: +public: + virtual void print() const = 0; +}; + +class ast_VariableDeclaration : public ast_Declaration { +private: + mutable std::vector<const ast_Base*> var_list; public: - ast_Declaration(const std::string _id) : id(_id) {} - virtual void print() const override { - std::cout << id; + ast_VariableDeclaration(const ast_Base* _var) { + var_list.push_back(_var); + } + + virtual void print() const { + for(int i = 0; i < var_list.size(); ++i) { + var_list[i]->print(); + } + } + + virtual void push(const ast_Base* _var) const { + var_list.push_back(_var); } }; |