mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 05:08:14 +00:00
Make trailing commas followed by a closing token on the same an error with -vet-style
This commit is contained in:
+13
-6
@@ -1411,12 +1411,13 @@ gb_internal Token expect_token(AstFile *f, TokenKind kind) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gb_internal Token expect_token_after(AstFile *f, TokenKind kind, char const *msg) {
|
gb_internal Token expect_token_after(AstFile *f, TokenKind kind, char const *msg) {
|
||||||
Token prev = f->curr_token;
|
Token prev = f->prev_token;
|
||||||
if (prev.kind != kind) {
|
Token curr = f->curr_token;
|
||||||
String p = token_to_string(prev);
|
if (curr.kind != kind) {
|
||||||
|
String p = token_to_string(curr);
|
||||||
Token token = f->curr_token;
|
Token token = f->curr_token;
|
||||||
if (token_is_newline(prev)) {
|
if (token_is_newline(curr)) {
|
||||||
token = prev;
|
token = curr;
|
||||||
token.pos.column -= 1;
|
token.pos.column -= 1;
|
||||||
skip_possible_newline(f);
|
skip_possible_newline(f);
|
||||||
}
|
}
|
||||||
@@ -1426,7 +1427,13 @@ gb_internal Token expect_token_after(AstFile *f, TokenKind kind, char const *msg
|
|||||||
LIT(p));
|
LIT(p));
|
||||||
}
|
}
|
||||||
advance_token(f);
|
advance_token(f);
|
||||||
return prev;
|
|
||||||
|
if (ast_file_vet_style(f) &&
|
||||||
|
prev.kind == Token_Comma &&
|
||||||
|
prev.pos.line == curr.pos.line) {
|
||||||
|
syntax_error(prev, "No need for a trailing comma followed by a %.*s on the same line", LIT(token_strings[kind]));
|
||||||
|
}
|
||||||
|
return curr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user