@@ -745,26 +745,38 @@ impl<'a> Parser<'a> {
745
745
}
746
746
};
747
747
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> {
748
764
let conditional_statements = if self.peek_keyword(Keyword::BEGIN) {
749
765
let begin_token = self.expect_keyword(Keyword::BEGIN)?;
750
766
let statements = self.parse_statement_list(terminal_keywords)?;
751
767
let end_token = self.expect_keyword(Keyword::END)?;
768
+
752
769
ConditionalStatements::BeginEnd(BeginEndStatements {
753
770
begin_token: AttachedToken(begin_token),
754
771
statements,
755
772
end_token: AttachedToken(end_token),
756
773
})
757
774
} else {
758
- let statements = self.parse_statement_list(terminal_keywords)?;
759
- ConditionalStatements::Sequence { statements }
775
+ ConditionalStatements::Sequence {
776
+ statements: self.parse_statements()?,
777
+ }
760
778
};
761
-
762
- Ok(ConditionalStatementBlock {
763
- start_token: AttachedToken(start_token),
764
- condition,
765
- then_token,
766
- conditional_statements,
767
- })
779
+ Ok(conditional_statements)
768
780
}
769
781
770
782
/// Parse a `RAISE` statement.
0 commit comments