From 8d3951a871c1442649c33bd3c4af7cc699b9ce64 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 15 Apr 2024 05:08:55 +0630 Subject: Implemented preprocesser function. --- asm/preprocesser.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'asm/preprocesser.cpp') 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, pp_err_t> preprocesser(vector &tokens) +{ + vector 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 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, pp_err_t> preprocess_use_blocks(const vector &tokens) { -- cgit v1.2.3-13-gbd6f