aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-08-31 23:47:20 +0100
committergingerBill <bill@gingerbill.org>2021-08-31 23:47:20 +0100
commit773a766b83c327069f3634ad982e29e9e06119e9 (patch)
treead6e73062cab750995d2cb0327686f9a9f83f9e0 /src/parser.cpp
parent169e717021d6b0f1016360c820bc81e801bf1e53 (diff)
Strip semicolon if followed by a `}` or `)` on the same line
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index fe421f7db..4433a0a7f 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1497,7 +1497,19 @@ void assign_removal_flag_to_semicolon(AstFile *f) {
Token *curr_token = &f->tokens[f->curr_token_index];
GB_ASSERT(prev_token->kind == Token_Semicolon);
if (prev_token->string == ";") {
+ bool ok = false;
if (curr_token->pos.line > prev_token->pos.line) {
+ ok = true;
+ } else if (curr_token->pos.line == prev_token->pos.line) {
+ switch (curr_token->kind) {
+ case Token_CloseBrace:
+ case Token_CloseParen:
+ ok = true;
+ break;
+ }
+ }
+
+ if (ok) {
if (build_context.strict_style) {
syntax_error(*prev_token, "Found unneeded semicolon");
}