Skip to content

Commit bfd767e

Browse files
committed
Move IF statement semi-colon logic into parse_if_stmt
- no need for special IF logic to bleed over to another function
1 parent 6d0ea64 commit bfd767e

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

src/dialect/mssql.rs

+6
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ impl MsSqlDialect {
169169
}
170170
};
171171

172+
let mut prior_statement_ended_with_semi_colon = false;
172173
while let Token::SemiColon = parser.peek_token_ref().token {
173174
parser.advance_token();
175+
prior_statement_ended_with_semi_colon = true;
174176
}
175177

176178
let mut else_block = None;
@@ -201,6 +203,10 @@ impl MsSqlDialect {
201203
},
202204
});
203205
}
206+
} else {
207+
if prior_statement_ended_with_semi_colon {
208+
parser.prev_token();
209+
}
204210
}
205211

206212
Ok(Statement::If(IfStatement {

src/parser/mod.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -4454,16 +4454,7 @@ impl<'a> Parser<'a> {
44544454
}
44554455
}
44564456
values.push(self.parse_statement()?);
4457-
4458-
let semi_colon_expected = match values.last() {
4459-
Some(Statement::If(if_statement)) => if_statement.end_token.is_some(),
4460-
Some(_) => true,
4461-
None => false,
4462-
};
4463-
4464-
if semi_colon_expected {
4465-
self.expect_token(&Token::SemiColon)?;
4466-
}
4457+
self.expect_token(&Token::SemiColon)?;
44674458
}
44684459
Ok(values)
44694460
}

0 commit comments

Comments
 (0)