diff options
| author | gingerBill <bill@gingerbill.org> | 2021-08-31 23:47:20 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-08-31 23:47:20 +0100 |
| commit | 773a766b83c327069f3634ad982e29e9e06119e9 (patch) | |
| tree | ad6e73062cab750995d2cb0327686f9a9f83f9e0 /src/parser.cpp | |
| parent | 169e717021d6b0f1016360c820bc81e801bf1e53 (diff) | |
Strip semicolon if followed by a `}` or `)` on the same line
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 12 |
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"); } |