diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-19 05:06:45 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-02-19 05:06:45 +0000 |
commit | 0e9e8dab385375c0cbb83d89a71fbf8d71206b47 (patch) | |
tree | bacb57c4e93652ac8348d7951c63f1796c9f7750 /c_parser/include | |
parent | 258c14392606ec4ba0a590cac80ba4198ef920d9 (diff) | |
download | Compiler-0e9e8dab385375c0cbb83d89a71fbf8d71206b47.tar.gz Compiler-0e9e8dab385375c0cbb83d89a71fbf8d71206b47.zip |
Finished if statement for the most part
Diffstat (limited to 'c_parser/include')
-rw-r--r-- | c_parser/include/ast.hpp | 1 | ||||
-rw-r--r-- | c_parser/include/ast_declaration.hpp | 2 | ||||
-rw-r--r-- | c_parser/include/ast_expression.hpp | 30 | ||||
-rw-r--r-- | c_parser/include/ast_statement.hpp | 14 |
4 files changed, 46 insertions, 1 deletions
diff --git a/c_parser/include/ast.hpp b/c_parser/include/ast.hpp index 787e928..b73506f 100644 --- a/c_parser/include/ast.hpp +++ b/c_parser/include/ast.hpp @@ -5,6 +5,7 @@ #include "ast_statement.hpp" #include "ast_function.hpp" #include "ast_declaration.hpp" +#include "ast_expression.hpp" #include "ast_primitives.hpp" #include "ast_top.hpp" diff --git a/c_parser/include/ast_declaration.hpp b/c_parser/include/ast_declaration.hpp index 72bd375..7bc8177 100644 --- a/c_parser/include/ast_declaration.hpp +++ b/c_parser/include/ast_declaration.hpp @@ -15,7 +15,7 @@ public: ast_DeclarationList(const ast_Base* _dec) { dec_list.push_back(_dec); } - + virtual void print() const { for(size_t i = 0; i < dec_list.size(); ++i) { dec_list[i]->print(); diff --git a/c_parser/include/ast_expression.hpp b/c_parser/include/ast_expression.hpp new file mode 100644 index 0000000..2e223f4 --- /dev/null +++ b/c_parser/include/ast_expression.hpp @@ -0,0 +1,30 @@ +#ifndef AST_EXPRESSION_HPP +#define AST_EXPRESSION_HPP + +#include "ast.hpp" + +#include <string> +#include <iostream> + +class ast_Expression : public ast_Base { +private: + std::string id; +public: + ast_Expression(const std::string& _id) : id(_id) {} + + virtual void print() const { + + } + + virtual void push(const ast_Base* _base) const { + std::cerr << "Can't call this function for this type" << std::endl; + (void)_base; + } +}; + +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 d3f6e96..e9864e9 100644 --- a/c_parser/include/ast_statement.hpp +++ b/c_parser/include/ast_statement.hpp @@ -63,4 +63,18 @@ public: } }; +class ast_SelectionStatement : public ast_Statement { +public: + ast_SelectionStatement() : ast_Statement() {} + ast_SelectionStatement(const ast_Base* _el) : ast_Statement(_el) {} + ast_SelectionStatement(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 |