@@ -745,26 +745,38 @@ impl<'a> Parser<'a> {
745745 }
746746 };
747747
748+ let conditional_statements = self.parse_conditional_statements(terminal_keywords)?;
749+
750+ Ok(ConditionalStatementBlock {
751+ start_token: AttachedToken(start_token),
752+ condition,
753+ then_token,
754+ conditional_statements,
755+ })
756+ }
757+
758+ /// Parse a BEGIN/END block or a sequence of statements
759+ /// This could be inside of a conditional (IF, CASE, WHILE etc.) or an object body defined optionally BEGIN/END and one or more statements.
760+ pub(crate) fn parse_conditional_statements(
761+ &mut self,
762+ terminal_keywords: &[Keyword],
763+ ) -> Result<ConditionalStatements, ParserError> {
748764 let conditional_statements = if self.peek_keyword(Keyword::BEGIN) {
749765 let begin_token = self.expect_keyword(Keyword::BEGIN)?;
750766 let statements = self.parse_statement_list(terminal_keywords)?;
751767 let end_token = self.expect_keyword(Keyword::END)?;
768+
752769 ConditionalStatements::BeginEnd(BeginEndStatements {
753770 begin_token: AttachedToken(begin_token),
754771 statements,
755772 end_token: AttachedToken(end_token),
756773 })
757774 } else {
758- let statements = self.parse_statement_list(terminal_keywords)?;
759- ConditionalStatements::Sequence { statements }
775+ ConditionalStatements::Sequence {
776+ statements: self.parse_statements()?,
777+ }
760778 };
761-
762- Ok(ConditionalStatementBlock {
763- start_token: AttachedToken(start_token),
764- condition,
765- then_token,
766- conditional_statements,
767- })
779+ Ok(conditional_statements)
768780 }
769781
770782 /// Parse a `RAISE` statement.
0 commit comments