fix: improve try_parse and parse functions in helper.hh
This commit is contained in:
parent
1c552c2c5c
commit
63f79a28e1
@ -51,20 +51,24 @@ namespace ppc::comp::tree::ast {
|
|||||||
else return ctx.tokens[res_i].location.intersect(loc());
|
else return ctx.tokens[res_i].location.intersect(loc());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool try_parse(const parser_t &parser, data::map_t &out, messages::msg_stack_t &messages) {
|
bool parse(const parser_t &parser, data::map_t &out) {
|
||||||
|
return parser(ctx, i, out);
|
||||||
|
}
|
||||||
|
bool try_parse(const parser_t &parser, data::map_t &out, bool silent = true) {
|
||||||
try {
|
try {
|
||||||
return parser(ctx, i, out);
|
return parser(ctx, i, out);
|
||||||
}
|
}
|
||||||
catch (messages::message_t msg) {
|
catch (messages::message_t msg) {
|
||||||
messages.push(msg);
|
if (!silent) ctx.messages.push(msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool try_parse(const parser_t &parser, data::map_t &out) {
|
bool try_parse(const parser_t &parser, data::map_t &out, message_t &err) {
|
||||||
try {
|
try {
|
||||||
return parser(ctx, i, out);
|
return parser(ctx, i, out);
|
||||||
}
|
}
|
||||||
catch (messages::message_t msg) {
|
catch (messages::message_t msg) {
|
||||||
|
err = msg;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user