mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Strip semicolon if followed by a } or ) on the same line
This commit is contained in:
@@ -1497,7 +1497,19 @@ void assign_removal_flag_to_semicolon(AstFile *f) {
|
|||||||
Token *curr_token = &f->tokens[f->curr_token_index];
|
Token *curr_token = &f->tokens[f->curr_token_index];
|
||||||
GB_ASSERT(prev_token->kind == Token_Semicolon);
|
GB_ASSERT(prev_token->kind == Token_Semicolon);
|
||||||
if (prev_token->string == ";") {
|
if (prev_token->string == ";") {
|
||||||
|
bool ok = false;
|
||||||
if (curr_token->pos.line > prev_token->pos.line) {
|
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) {
|
if (build_context.strict_style) {
|
||||||
syntax_error(*prev_token, "Found unneeded semicolon");
|
syntax_error(*prev_token, "Found unneeded semicolon");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user