diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-19 13:59:24 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-19 13:59:24 +0000 |
commit | 1802437f63e14c1128918c4e3a00f60fb97182d9 (patch) | |
tree | 8d4b47072cb81868bb04d4d475682e02bf429ad1 /c_parser/include | |
parent | 0e9e8dab385375c0cbb83d89a71fbf8d71206b47 (diff) | |
download | Compiler-1802437f63e14c1128918c4e3a00f60fb97182d9.tar.gz Compiler-1802437f63e14c1128918c4e3a00f60fb97182d9.zip |
FInished parser but still have one shift/reduce warning
Diffstat (limited to 'c_parser/include')
-rw-r--r-- | c_parser/include/ast_expression.hpp | 8 | ||||
-rw-r--r-- | c_parser/include/ast_statement.hpp | 42 |
2 files changed, 43 insertions, 7 deletions
diff --git a/c_parser/include/ast_expression.hpp b/c_parser/include/ast_expression.hpp index 2e223f4..87db997 100644 --- a/c_parser/include/ast_expression.hpp +++ b/c_parser/include/ast_expression.hpp @@ -8,9 +8,8 @@ class ast_Expression : public ast_Base { private: - std::string id; public: - ast_Expression(const std::string& _id) : id(_id) {} + ast_Expression() {} virtual void print() const { @@ -22,9 +21,4 @@ public: } }; -class ast_ReturnExpression : public ast_Expression { -public: - ast_ReturnExpression(const std::string& _id) : ast_Expression(_id) {} -}; - #endif diff --git a/c_parser/include/ast_statement.hpp b/c_parser/include/ast_statement.hpp index e9864e9..224a809 100644 --- a/c_parser/include/ast_statement.hpp +++ b/c_parser/include/ast_statement.hpp @@ -77,4 +77,46 @@ public: } }; +class ast_ExpressionStatement : public ast_Statement { +public: + ast_ExpressionStatement() : ast_Statement() {} + ast_ExpressionStatement(const ast_Base* _el) : ast_Statement(_el) {} + ast_ExpressionStatement(const ast_Base* _if, const ast_Base* _else) : + ast_Statement(_if, _else) {} + + virtual void print() const override { + for(size_t i = 0; i < ast_list.size(); ++i) { + ast_list[i]->print(); + } + } +}; + +class ast_JumpStatement : public ast_Statement { +public: + ast_JumpStatement() : ast_Statement() {} + ast_JumpStatement(const ast_Base* _el) : ast_Statement(_el) {} + ast_JumpStatement(const ast_Base* _if, const ast_Base* _else) : + ast_Statement(_if, _else) {} + + virtual void print() const override { + for(size_t i = 0; i < ast_list.size(); ++i) { + ast_list[i]->print(); + } + } +}; + +class ast_IterationStatement : public ast_Statement { +public: + ast_IterationStatement() : ast_Statement() {} + ast_IterationStatement(const ast_Base* _el) : ast_Statement(_el) {} + ast_IterationStatement(const ast_Base* _if, const ast_Base* _else) : + ast_Statement(_if, _else) {} + + virtual void print() const override { + for(size_t i = 0; i < ast_list.size(); ++i) { + ast_list[i]->print(); + } + } +}; + #endif |