diff options
| author | gingerBill <bill@gingerbill.org> | 2019-09-04 18:10:02 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-09-04 18:10:02 +0100 |
| commit | d54255505a1b7b2a460ce7f4a18ea30a92286aa1 (patch) | |
| tree | db1b0bc566c8e9e9e5b5db65788d21369c96f5d2 /src/parser.cpp | |
| parent | d4914c3546b45ebca11d489481e58ecbd7f4e6a0 (diff) | |
Fix Compiler does not complain about missing semicolon #433
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index b1d9a457f..123e1fcee 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -1370,10 +1370,6 @@ void expect_semicolon(AstFile *f, Ast *s) { return; } - switch (f->curr_token.kind) { - case Token_EOF: - return; - } if (s != nullptr) { if (prev_token.pos.line != f->curr_token.pos.line) { @@ -1386,12 +1382,21 @@ void expect_semicolon(AstFile *f, Ast *s) { case Token_CloseParen: case Token_else: return; + case Token_EOF: + if (is_semicolon_optional_for_node(f, s)) { + return; + } + break; } } String node_string = ast_strings[s->kind]; syntax_error(prev_token, "Expected ';' after %.*s, got %.*s", - LIT(node_string), LIT(token_strings[prev_token.kind])); + LIT(node_string), LIT(token_strings[f->curr_token.kind])); } else { + switch (f->curr_token.kind) { + case Token_EOF: + return; + } syntax_error(prev_token, "Expected ';'"); } fix_advance_to_next_stmt(f); |