diff options
| author | gingerBill <bill@gingerbill.org> | 2021-03-13 23:17:56 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-03-13 23:17:56 +0000 |
| commit | 8f6439fa6ba78f17a2c6fcc7f2be7eaa9082a728 (patch) | |
| tree | 9295d2b3ce88c1b79e2ff2e6957047b4789e4529 /src/parser.cpp | |
| parent | 81efd2dc64d63a7d75db7f34fe340d32e02573ba (diff) | |
Simplify `expect_semicolon_newline_error` rule
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index d7706040e..3e2df2c55 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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"); } } |