diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-15 05:56:01 +0630 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-15 05:56:01 +0630 |
commit | 958868714eb0c248865eae19e642f5d95dcffc54 (patch) | |
tree | 3111697d929144cbb72151f39a9b80c1ab244218 | |
parent | e22ed450ac2f86787f455f529d6ad1a2ccb33260 (diff) | |
download | ovm-958868714eb0c248865eae19e642f5d95dcffc54.tar.gz ovm-958868714eb0c248865eae19e642f5d95dcffc54.tar.bz2 ovm-958868714eb0c248865eae19e642f5d95dcffc54.zip |
main.cpp now preprocesses tokens and prints the output
-rw-r--r-- | asm/main.cpp | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/asm/main.cpp b/asm/main.cpp index c2414b8..61ec667 100644 --- a/asm/main.cpp +++ b/asm/main.cpp @@ -22,6 +22,7 @@ #include "./base.hpp" #include "./lexer.hpp" +#include "./preprocesser.hpp" using std::pair, std::string, std::string_view, std::vector; @@ -48,8 +49,11 @@ int main(int argc, const char *argv[]) string source_str; string_view original; string_view src; - vector<token_t *> tokens; + vector<token_t *> tokens, preprocessed_tokens; lerr_t lerr; + pp_err_t pp_err; + + // Highest scoped variable cut off point if (file_source.has_value()) source_str = file_source.value(); @@ -86,15 +90,40 @@ int main(int argc, const char *argv[]) } else { + std::cout << "LEXER: \n" + "-------------------------------------------------------------" + "-------------------\n"; for (auto token : tokens) - { - std::cout << "\t" << token << std::endl; - } + std::cout << "\t" << *token << std::endl; + std::cout << "-------------------------------------------------------------" + "-------------------\n"; + } + + // preprocessing + std::tie(preprocessed_tokens, pp_err) = preprocesser(tokens); + if (pp_err.type != pp_err_type_t::OK) + { + std::cerr << file_name << ":" << pp_err.reference->line << ":" + << pp_err.reference->column << ":" << pp_err << std::endl; + ret = 255 - static_cast<int>(pp_err.type); + goto end; + } + else + { + std::cout << "PREPROCESSER: \n" + "-------------------------------------------------------------" + "-------------------\n"; + for (auto token : preprocessed_tokens) + std::cout << "\t" << *token << std::endl; + std::cout << "-------------------------------------------------------------" + "-------------------\n"; } end: for (auto token : tokens) delete token; + for (auto token : preprocessed_tokens) + delete token; return ret; } |