refactor: modify ast_ctx_t::parse signature to fit other stages
This commit is contained in:
parent
0c7961ca6b
commit
eb8d7cd1f1
@ -73,7 +73,7 @@ namespace ppc::comp::tree::ast {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool parse(std::string parser, size_t &pi, data::map_t &out);
|
bool parse(std::string parser, size_t &pi, data::map_t &out);
|
||||||
static bool parse(msg_stack_t &messages, std::vector<token_t> &tokens, data::map_t &out);
|
static data::map_t parse(msg_stack_t &messages, std::vector<token_t> &tokens);
|
||||||
|
|
||||||
~ast_ctx_t();
|
~ast_ctx_t();
|
||||||
ast_ctx_t(msg_stack_t &messages, std::vector<token_t> &tokens):
|
ast_ctx_t(msg_stack_t &messages, std::vector<token_t> &tokens):
|
||||||
|
@ -30,18 +30,14 @@ namespace ppc::comp::tree::ast {
|
|||||||
groups.emplace(parser);
|
groups.emplace(parser);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ast_ctx_t::parse(msg_stack_t &messages, std::vector<token_t> &tokens, data::map_t &out) {
|
data::map_t ast_ctx_t::parse(msg_stack_t &messages, std::vector<token_t> &tokens) {
|
||||||
ast_ctx_t ctx(messages, tokens);
|
ast_ctx_t ctx(messages, tokens);
|
||||||
ctx.init();
|
ctx.init();
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
|
data::map_t res;
|
||||||
|
|
||||||
try {
|
if (!ctx.parse("$_glob", i, res)) throw message_t::error("Failed to compile.");
|
||||||
return ctx.parse("$_glob", i, out);
|
return res;
|
||||||
}
|
|
||||||
catch (const message_t &msg) {
|
|
||||||
messages.push(msg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
bool ast_ctx_t::parse(std::string parser, size_t &pi, data::map_t &out) {
|
bool ast_ctx_t::parse(std::string parser, size_t &pi, data::map_t &out) {
|
||||||
return this->parser[parser] (*this, pi, out);
|
return this->parser[parser] (*this, pi, out);
|
||||||
|
Loading…
Reference in New Issue
Block a user