diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -1672,7 +1672,16 @@ static int pars_parse_expr( unsigned nesting = 0; // Otherwise expect open parenthesis, number, or unary operator. bool expect_close_or_binary = false; - while (!pars_is_eof_reached(self)) { + while (1) { + if (pars_is_eof_reached(self)) { + if (nesting != 0) { + assert(pars_is_eof_reached(self)); + return pars_yield_error_eof( + self, + expect_close_or_binary ? E_EXPR_CLOSE : E_EXPR_OPEN); + } + break; + } const struct token token = pars_peek(self); if (token.type == TT_LPAREN) { if (expect_close_or_binary) { @@ -1730,12 +1739,6 @@ static int pars_parse_expr( pars_commit(self); } assert(first_token_id != self->cur_tok_id); - if (nesting != 0) { - assert(pars_is_eof_reached(self)); - return pars_yield_error_eof( - self, - expect_close_or_binary ? E_EXPR_CLOSE : E_EXPR_OPEN); - } *expr = (struct expr_tokens_span){ .first_token = first_token_id, .num_tokens = self->cur_tok_id - first_token_id, |