aboutsummaryrefslogtreecommitdiff
path: root/src/parser.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-12-09 23:40:45 +0000
committergingerBill <bill@gingerbill.org>2020-12-09 23:40:45 +0000
commitf64584b92a54dceb28121461f2ef4fd02c7b30de (patch)
tree67fd197aebc760d5b08356ba3b87d5cf93b3fb1b /src/parser.cpp
parent9eb12889f416f63e635410a1217a9f34c3f2c9cd (diff)
Improve -insert-semicolon rules
Diffstat (limited to 'src/parser.cpp')
-rw-r--r--src/parser.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/parser.cpp b/src/parser.cpp
index 6e64ee9a8..59d02090e 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -3181,6 +3181,7 @@ Ast *parse_simple_stmt(AstFile *f, u32 flags) {
Ast *parse_block_stmt(AstFile *f, b32 is_when) {
+ skip_possible_newline_for_literal(f);
if (!is_when && f->curr_proc == nullptr) {
syntax_error(f->curr_token, "You cannot use a block statement in the file scope");
return ast_bad_stmt(f, f->curr_token, f->curr_token);
@@ -3794,17 +3795,16 @@ Ast *parse_if_stmt(AstFile *f) {
syntax_error(body, "The body of a 'do' be on the same line as if condition");
}
} else {
- skip_possible_newline_for_literal(f);
body = parse_block_stmt(f, false);
}
+ skip_possible_newline_for_literal(f);
if (allow_token(f, Token_else)) {
switch (f->curr_token.kind) {
case Token_if:
else_stmt = parse_if_stmt(f);
break;
case Token_OpenBrace:
- skip_possible_newline_for_literal(f);
else_stmt = parse_block_stmt(f, false);
break;
case Token_do: {
@@ -3851,10 +3851,10 @@ Ast *parse_when_stmt(AstFile *f) {
syntax_error(body, "The body of a 'do' be on the same line as when statement");
}
} else {
- skip_possible_newline_for_literal(f);
body = parse_block_stmt(f, true);
}
+ skip_possible_newline_for_literal(f);
if (allow_token(f, Token_else)) {
switch (f->curr_token.kind) {
case Token_when:
@@ -3957,7 +3957,6 @@ Ast *parse_for_stmt(AstFile *f) {
syntax_error(body, "The body of a 'do' be on the same line as the 'for' token");
}
} else {
- skip_possible_newline_for_literal(f);
body = parse_block_stmt(f, false);
}
return ast_range_stmt(f, token, nullptr, nullptr, in_token, rhs, body);
@@ -3993,7 +3992,6 @@ Ast *parse_for_stmt(AstFile *f) {
syntax_error(body, "The body of a 'do' be on the same line as the 'for' token");
}
} else {
- skip_possible_newline_for_literal(f);
body = parse_block_stmt(f, false);
}
@@ -4345,7 +4343,6 @@ Ast *parse_stmt(AstFile *f) {
syntax_error(body, "The body of a 'do' be on the same line as the 'for' token");
}
} else {
- skip_possible_newline_for_literal(f);
body = parse_block_stmt(f, false);
}
if (bad_stmt) {