AST building #2

Merged
TopchetoEU merged 74 commits from TopchetoEU/ast-building into master 2022-10-28 11:58:03 +00:00
2 changed files with 6 additions and 3 deletions
Showing only changes of commit 1b6d29ff7b - Show all commits

View File

@ -199,7 +199,10 @@ bool ast::parse_exp(ast_ctx_t &ctx, size_t &res_i, map_t &out) {
h.advance("Expected a value on the right side of the operator.");
continue;
}
if (!last_val && h.push_parse(ctx.group("$_exp_val"), res)) last_val = true;
if (!last_val && h.push_parse(ctx.group("$_exp_val"), res)) {
last_val = true;
continue;
}
if (h.curr().is_operator()) {
auto op = h.curr()._operator();
if (last_val) {
@ -315,7 +318,7 @@ bool ast::parse_exp(ast_ctx_t &ctx, size_t &res_i, map_t &out) {
bool ast::parse_stat_exp(ast_ctx_t &ctx, size_t &i, map_t &res) {
tree_helper_t h(ctx, i);
if (!h.parse(parse_exp, res)) return false;
if (h.curr().is_operator(operator_t::SEMICOLON)) return h.submit(true);
if (!h.ended() && h.curr().is_operator(operator_t::SEMICOLON)) return h.submit(true);
ctx.messages.push(message_t::error("Expected a semicolon.", h.loc(1)));
return h.submit(false);

View File

@ -22,7 +22,7 @@ bool ast::parse_field(ast_ctx_t &ctx, size_t &res_i, map_t &out) {
type = true;
}
if (h.curr().is_operator(operator_t::SEMICOLON)) {
if (!h.ended() && h.curr().is_operator(operator_t::SEMICOLON)) {
if (type || defval) return h.submit();
else return h.err("A type or a default value must be specified ");
}