Merge pull request #2649 from hchac/allow-newline-field-list-separator

Match C++ parser behavior in allowing newlines before a closing brace.
This commit is contained in:
gingerBill
2023-08-07 11:45:08 +01:00
committed by GitHub

View File

@@ -420,7 +420,7 @@ expect_closing_brace_of_field_list :: proc(p: ^Parser) -> tokenizer.Token {
if allow_token(p, .Close_Brace) {
return token
}
if allow_token(p, .Semicolon) {
if allow_token(p, .Semicolon) && !tokenizer.is_newline(token) {
str := tokenizer.token_to_string(token)
error(p, end_of_line_pos(p, p.prev_tok), "expected a comma, got %s", str)
}
@@ -1836,7 +1836,9 @@ parse_field_list :: proc(p: ^Parser, follow: tokenizer.Token_Kind, allowed_flags
return true
}
if allow_token(p, .Semicolon) {
error(p, tok.pos, "expected a comma, got a semicolon")
if !tokenizer.is_newline(tok) {
error(p, tok.pos, "expected a comma, got a semicolon")
}
return true
}
return false