diff options
| author | Ginger Bill <bill@gingerbill.org> | 2016-12-05 23:39:26 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2016-12-05 23:39:26 +0000 |
| commit | a16bdb215a31e66ae8a3d9132483f287fc7f53eb (patch) | |
| tree | 980e4c21f1a74a831152c7812bee1c5219d45849 /src/parser.c | |
| parent | 88aa74bbb9043f4ffe843beacb0984c06a1dfff3 (diff) | |
Go/BCPL style semicolon insertion during tokenizing stage
Diffstat (limited to 'src/parser.c')
| -rw-r--r-- | src/parser.c | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/src/parser.c b/src/parser.c index 28925fb57..7eeb9133f 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1158,26 +1158,6 @@ bool expect_semicolon_after_stmt(AstFile *f, AstNode *s) { } if (s != NULL) { - switch (s->kind) { - case AstNode_ProcDecl: - case AstNode_TypeDecl: - return true; - } - } - - // if (f->curr_token.pos.line != f->prev_token.pos.line) { - // return true; - // } - - if (f->curr_token.pos.line == f->prev_token.pos.line) { - switch (f->curr_token.kind) { - case Token_EOF: - case Token_CloseBrace: - return true; - } - } - - if (s != NULL) { syntax_error(f->prev_token, "Expected `;` after %.*s, got `%.*s`", LIT(ast_node_strings[s->kind]), LIT(token_strings[f->prev_token.kind])); } else { @@ -2222,10 +2202,14 @@ AstNode *parse_identifier_or_type(AstFile *f, u32 flags) { break; } // fallthrough - default: + default: { + String prev = str_lit("newline"); + if (str_ne(f->prev_token.string, str_lit("\n"))) { + prev = f->prev_token.string; + } syntax_error(f->curr_token, - "Expected a type or identifier after `%.*s`, got `%.*s`", LIT(f->prev_token.string), LIT(f->curr_token.string)); - break; + "Expected a type or identifier after %.*s, got %.*s", LIT(prev), LIT(f->curr_token.string)); + } break; } return NULL; |