diff options
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; +} |