Simplify expect_semicolon_newline_error rule

This commit is contained in:
gingerBill
2021-03-13 23:17:56 +00:00
parent 81efd2dc64
commit 8f6439fa6b

View File

@@ -1536,25 +1536,20 @@ bool is_semicolon_optional_for_node(AstFile *f, Ast *s) {
}
void expect_semicolon_newline_error(AstFile *f, Token const &token, Ast *s) {
if (build_context.strict_style) {
if (f->curr_proc != nullptr && token.string == "\n") {
switch (token.kind) {
case Token_CloseBrace:
case Token_CloseParen:
case Token_else:
case Token_EOF:
return;
}
if (s != nullptr) {
if (is_semicolon_optional_for_node(f, s)) {
return;
}
}
Token tok = token;
tok.pos.column -= 1;
syntax_error(tok, "Expected ';', got newline");
if (build_context.strict_style && token.string == "\n") {
switch (token.kind) {
case Token_CloseBrace:
case Token_CloseParen:
case Token_else:
return;
}
if (is_semicolon_optional_for_node(f, s)) {
return;
}
Token tok = token;
tok.pos.column -= 1;
syntax_error(tok, "Expected ';', got newline");
}
}