diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-05 20:55:12 +0000 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2017-03-05 20:55:12 +0000 |
commit | eccb6c5360f213675a513e875bc424b8bdee16e7 (patch) | |
tree | 88b2826a2898223bcd5f02d5e5fd1f2c1c9b7e2a /c_compiler/src/declaration.cpp | |
parent | 6b7f5137edb18372bc3e3076dab1cb45c8e4c2ec (diff) | |
download | Compiler-eccb6c5360f213675a513e875bc424b8bdee16e7.tar.gz Compiler-eccb6c5360f213675a513e875bc424b8bdee16e7.zip |
Finished ast change and it works
Diffstat (limited to 'c_compiler/src/declaration.cpp')
-rw-r--r-- | c_compiler/src/declaration.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/c_compiler/src/declaration.cpp b/c_compiler/src/declaration.cpp new file mode 100644 index 0000000..5341b5b --- /dev/null +++ b/c_compiler/src/declaration.cpp @@ -0,0 +1,51 @@ +#include "ast.hpp" + + +// Declaration definition + +Declaration::Declaration(const std::string& _id) + : id(_id) {} + +void Declaration::print() const +{ + if(next_decl != nullptr) + next_decl->print(); + + if(id != "") + std::cout << id << std::endl; +} + +void Declaration::printxml() const +{ + if(next_decl != nullptr) + next_decl->printxml(); + + if(decl_list != nullptr) { + decl_list->printxml(); + } + + if(id != "") + std::cout << "<Variable id=\""<< id << "\" />" << std::endl; +} + +void Declaration::printasm() const {} + +void Declaration::addDeclaration(Declaration* _next_decl) +{ + next_decl = _next_decl; +} + +void Declaration::addList(Declaration* _next_decl) +{ + decl_list = _next_decl; +} + +Declaration* Declaration::getNext() const +{ + return next_decl; +} + +std::string Declaration::getId() const +{ + return id; +} |