diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-15 05:08:55 +0630 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-15 05:08:55 +0630 |
commit | 8d3951a871c1442649c33bd3c4af7cc699b9ce64 (patch) | |
tree | e872647780a3e19c5cd61df4cb4e261d5742aeb2 | |
parent | 1e1a13e741eb286930e669f8fb0195c943243b4e (diff) | |
download | ovm-8d3951a871c1442649c33bd3c4af7cc699b9ce64.tar.gz ovm-8d3951a871c1442649c33bd3c4af7cc699b9ce64.tar.bz2 ovm-8d3951a871c1442649c33bd3c4af7cc699b9ce64.zip |
Implemented preprocesser function.
-rw-r--r-- | asm/preprocesser.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/asm/preprocesser.cpp b/asm/preprocesser.cpp index 8ac091b..6971d2b 100644 --- a/asm/preprocesser.cpp +++ b/asm/preprocesser.cpp @@ -21,6 +21,27 @@ using std::pair, std::vector, std::make_pair, std::string, std::string_view; #define ERR(E) std::make_pair(tokens, (E)) #define VAL(E) std::make_pair(E, pp_err_t{pp_err_type_t::OK}) +pair<vector<token_t *>, pp_err_t> preprocesser(vector<token_t *> &tokens) +{ + vector<token_t *> use_block_tokens; + pp_err_t pperr{pp_err_type_t::OK}; + std::tie(use_block_tokens, pperr) = preprocess_use_blocks(tokens); + if (pperr.type != pp_err_type_t::OK) + return ERR(pperr); + + vector<token_t *> const_block_tokens; + std::tie(const_block_tokens, pperr) = preprocess_const_blocks(tokens); + if (pperr.type != pp_err_type_t::OK) + { + tokens.clear(); + tokens = use_block_tokens; + return ERR(pperr); + } + + use_block_tokens.clear(); + return VAL(const_block_tokens); +} + pair<vector<token_t *>, pp_err_t> preprocess_use_blocks(const vector<token_t *> &tokens) { |