fix: some issues with missing semicolons at EOF

This commit is contained in:
TopchetoEU 2022-10-28 11:10:48 +03:00
parent b8400f0ec3
commit 1b6d29ff7b
2 changed files with 6 additions and 3 deletions

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."); h.advance("Expected a value on the right side of the operator.");
continue; 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()) { if (h.curr().is_operator()) {
auto op = h.curr()._operator(); auto op = h.curr()._operator();
if (last_val) { 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) { bool ast::parse_stat_exp(ast_ctx_t &ctx, size_t &i, map_t &res) {
tree_helper_t h(ctx, i); tree_helper_t h(ctx, i);
if (!h.parse(parse_exp, res)) return false; 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))); ctx.messages.push(message_t::error("Expected a semicolon.", h.loc(1)));
return h.submit(false); 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; 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(); if (type || defval) return h.submit();
else return h.err("A type or a default value must be specified "); else return h.err("A type or a default value must be specified ");
} }