Go/BCPL style semicolon insertion during tokenizing stage

This commit is contained in:
Ginger Bill
2016-12-05 23:39:26 +00:00
parent 88aa74bbb9
commit a16bdb215a
18 changed files with 3025 additions and 2906 deletions
+7 -23
View File
@@ -1157,26 +1157,6 @@ bool expect_semicolon_after_stmt(AstFile *f, AstNode *s) {
return true;
}
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]));
@@ -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;