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/translation_unit.cpp | |
parent | 6b7f5137edb18372bc3e3076dab1cb45c8e4c2ec (diff) | |
download | Compiler-eccb6c5360f213675a513e875bc424b8bdee16e7.tar.gz Compiler-eccb6c5360f213675a513e875bc424b8bdee16e7.zip |
Finished ast change and it works
Diffstat (limited to 'c_compiler/src/translation_unit.cpp')
-rw-r--r-- | c_compiler/src/translation_unit.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/c_compiler/src/translation_unit.cpp b/c_compiler/src/translation_unit.cpp new file mode 100644 index 0000000..c1e4c13 --- /dev/null +++ b/c_compiler/src/translation_unit.cpp @@ -0,0 +1,32 @@ +#include "ast.hpp" + + +// Translation Unit definition + +TranslationUnit::TranslationUnit(Node* decl) { + push(decl); +} + +void TranslationUnit::print() const { + for(auto& node : translation_unit) { + node->print(); + } +} + +void TranslationUnit::printxml() const { + std::cout << "<?xml version=\"1.0\"?>\n<Program>" << std::endl; + for(auto& node : translation_unit) { + node->printxml(); + } + std::cout << "</Program>" << std::endl; +} + +void TranslationUnit::printasm() const { + for(auto& node : translation_unit) { + node->printasm(); + } +} + +void TranslationUnit::push(Node* decl) { + translation_unit.push_back(decl); +} |