aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2025-02-24 13:13:36 +0000
committergingerBill <bill@gingerbill.org>2025-02-24 13:13:36 +0000
commitd23453811d3b8f5518845b412b9044a5bb5e92fb (patch)
tree4ca07ebf7d0df0155eac6c8c797cf639b0f2098e /src
parentc0b923c1c640d3ece556ee23740a6460f48061a8 (diff)
Improve semicolon checking rules when parsing
Diffstat (limited to 'src')
-rw-r--r--src/parser.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index f09590a55..f38f79607 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -3016,9 +3016,10 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
syntax_error(token, "Expected a type or range, got nothing");
}
- if (allow_token(f, Token_Semicolon)) {
+ if (f->curr_token.kind == Token_Semicolon && f->curr_token.string == ";") {
+ expect_token(f, Token_Semicolon);
underlying = parse_type(f);
- } else if (allow_token(f, Token_Comma)) {
+ } else if (allow_token(f, Token_Comma) || allow_token(f, Token_Semicolon)) {
String p = token_to_string(f->prev_token);
syntax_error(token_end_of_line(f, f->prev_token), "Expected a semicolon, got a %.*s", LIT(p));
@@ -4578,6 +4579,9 @@ gb_internal Ast *parse_do_body(AstFile *f, Token const &token, char const *msg)
gb_internal bool parse_control_statement_semicolon_separator(AstFile *f) {
Token tok = peek_token(f);
if (tok.kind != Token_OpenBrace) {
+ if (f->curr_token.kind == Token_Semicolon && f->curr_token.string != ";") {
+ syntax_error(token_end_of_line(f, f->prev_token), "Expected ';', got newline");
+ }
return allow_token(f, Token_Semicolon);
}
if (f->curr_token.string == ";") {