aboutsummaryrefslogtreecommitdiff
path: root/asm/preprocesser.cpp
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-04-15 05:08:55 +0630
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-04-15 05:08:55 +0630
commit8d3951a871c1442649c33bd3c4af7cc699b9ce64 (patch)
treee872647780a3e19c5cd61df4cb4e261d5742aeb2 /asm/preprocesser.cpp
parent1e1a13e741eb286930e669f8fb0195c943243b4e (diff)
downloadovm-8d3951a871c1442649c33bd3c4af7cc699b9ce64.tar.gz
ovm-8d3951a871c1442649c33bd3c4af7cc699b9ce64.tar.bz2
ovm-8d3951a871c1442649c33bd3c4af7cc699b9ce64.zip
Implemented preprocesser function.
Diffstat (limited to 'asm/preprocesser.cpp')
-rw-r--r--asm/preprocesser.cpp21
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)
{