diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-17 21:55:16 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-17 21:55:16 +0000 |
commit | 850f46eeb6de286d4b079373104af87e3aca781c (patch) | |
tree | 9f5f3c7b73d1447487030112c03c112ca85c7e55 /c_parser/include | |
parent | ce93fb7754f4565f70fe5572bd7d4a2c368ea9cd (diff) | |
download | Compiler-850f46eeb6de286d4b079373104af87e3aca781c.tar.gz Compiler-850f46eeb6de286d4b079373104af87e3aca781c.zip |
Finished functions completely, now moving on to statements
Diffstat (limited to 'c_parser/include')
-rw-r--r-- | c_parser/include/ast_statement.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/c_parser/include/ast_statement.hpp b/c_parser/include/ast_statement.hpp index f2c7175..d3f6e96 100644 --- a/c_parser/include/ast_statement.hpp +++ b/c_parser/include/ast_statement.hpp @@ -1,16 +1,41 @@ #ifndef AST_STATEMENT_HPP #define AST_STATEMENT_HPP +class ast_StatementList : public ast_Base { +protected: + mutable std::vector<const ast_Base*> statement_list; + +public: + ast_StatementList(const ast_Base* _statement) { + statement_list.push_back(_statement); + } + + virtual void print() const { + for(size_t i = 0; i < statement_list.size(); ++i) { + statement_list[i]->print(); + } + } + + virtual void push(const ast_Base* _statement) const { + statement_list.push_back(_statement); + } +}; + class ast_Statement : public ast_Base { protected: mutable std::vector<const ast_Base*> ast_list; public: ast_Statement() {} + ast_Statement(const ast_Base* _el) { ast_list.push_back(_el); } + ast_Statement(const ast_Base* _dec, const ast_Base* _statement) { + ast_list.push_back(_dec); + ast_list.push_back(_statement); + } virtual void print() const { for(size_t i = 0; i < ast_list.size(); ++i) { ast_list[i]->print(); @@ -26,6 +51,8 @@ class ast_CompoundStatement : public ast_Statement { public: ast_CompoundStatement() : ast_Statement() {} ast_CompoundStatement(const ast_Base* _el) : ast_Statement(_el) {} + ast_CompoundStatement(const ast_Base* _dec, const ast_Base* _statement) : + ast_Statement(_dec, _statement) {} virtual void print() const override { std::cout << "<Scope>" << std::endl; |