From 1b6d29ff7b3c21ebd9693604409e1e7f6afccc63 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Fri, 28 Oct 2022 11:10:48 +0300 Subject: [PATCH] fix: some issues with missing semicolons at EOF --- src/compiler/treeifier/ast/parsers/exp.cc | 7 +++++-- src/compiler/treeifier/ast/parsers/field.cc | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compiler/treeifier/ast/parsers/exp.cc b/src/compiler/treeifier/ast/parsers/exp.cc index 7991e2e..840335c 100644 --- a/src/compiler/treeifier/ast/parsers/exp.cc +++ b/src/compiler/treeifier/ast/parsers/exp.cc @@ -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); diff --git a/src/compiler/treeifier/ast/parsers/field.cc b/src/compiler/treeifier/ast/parsers/field.cc index e454884..a879a1d 100644 --- a/src/compiler/treeifier/ast/parsers/field.cc +++ b/src/compiler/treeifier/ast/parsers/field.cc @@ -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 "); }