aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2024-06-29 19:14:24 +0100
committergingerBill <bill@gingerbill.org>2024-06-29 19:14:24 +0100
commit2187f3e7ff076ea6375b1a09e32908a00e479dc8 (patch)
treeb87cc90d1e10c49910dceb8904c1755282537b29 /src
parent5413a8b744deba571287cc830e017369c46e847b (diff)
`-strict-style` enforce 1TBS (mostly)
Diffstat (limited to 'src')
-rw-r--r--src/parser.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index b1a179573..9b27ae156 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -1486,7 +1486,7 @@ gb_internal bool skip_possible_newline(AstFile *f) {
return false;
}
-gb_internal bool skip_possible_newline_for_literal(AstFile *f) {
+gb_internal bool skip_possible_newline_for_literal(AstFile *f, bool seen_where=false) {
Token curr = f->curr_token;
if (token_is_newline(curr)) {
Token next = peek_token(f);
@@ -1494,6 +1494,10 @@ gb_internal bool skip_possible_newline_for_literal(AstFile *f) {
switch (next.kind) {
case Token_OpenBrace:
case Token_else:
+ if (build_context.strict_style && !seen_where) {
+ syntax_error(next, "With '-strict-style' the attached brace style (1TBS) is enforced");
+ }
+ /*fallthrough*/
case Token_where:
advance_token(f);
return true;
@@ -2517,7 +2521,7 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
return type;
}
- skip_possible_newline_for_literal(f);
+ skip_possible_newline_for_literal(f, where_token.kind == Token_where);
if (allow_token(f, Token_Uninit)) {
if (where_token.kind != Token_Invalid) {
@@ -4499,6 +4503,9 @@ gb_internal bool parse_control_statement_semicolon_separator(AstFile *f) {
}
+
+
+
gb_internal Ast *parse_if_stmt(AstFile *f) {
if (f->curr_proc == nullptr) {
syntax_error(f->curr_token, "You cannot use an if statement in the file scope");