diff --git a/include/compiler/treeifier/ast.hh b/include/compiler/treeifier/ast.hh index 47c3443..e4c80ef 100644 --- a/include/compiler/treeifier/ast.hh +++ b/include/compiler/treeifier/ast.hh @@ -73,7 +73,7 @@ namespace ppc::comp::tree::ast { } bool parse(std::string parser, size_t &pi, data::map_t &out); - static bool parse(msg_stack_t &messages, std::vector &tokens, data::map_t &out); + static data::map_t parse(msg_stack_t &messages, std::vector &tokens); ~ast_ctx_t(); ast_ctx_t(msg_stack_t &messages, std::vector &tokens): diff --git a/src/compiler/treeifier/ast.cc b/src/compiler/treeifier/ast.cc index 7a30834..b93e5e4 100644 --- a/src/compiler/treeifier/ast.cc +++ b/src/compiler/treeifier/ast.cc @@ -30,18 +30,14 @@ namespace ppc::comp::tree::ast { groups.emplace(parser); } - bool ast_ctx_t::parse(msg_stack_t &messages, std::vector &tokens, data::map_t &out) { + data::map_t ast_ctx_t::parse(msg_stack_t &messages, std::vector &tokens) { ast_ctx_t ctx(messages, tokens); ctx.init(); size_t i = 0; + data::map_t res; - try { - return ctx.parse("$_glob", i, out); - } - catch (const message_t &msg) { - messages.push(msg); - return false; - } + if (!ctx.parse("$_glob", i, res)) throw message_t::error("Failed to compile."); + return res; } bool ast_ctx_t::parse(std::string parser, size_t &pi, data::map_t &out) { return this->parser[parser] (*this, pi, out);