Parses a list of match case blocks.
(&mut self)
| 2766 | |
| 2767 | /// Parses a list of match case blocks. |
| 2768 | fn parse_match_case_blocks(&mut self) -> Vec<ast::MatchCase> { |
| 2769 | let mut cases = vec![]; |
| 2770 | |
| 2771 | if !self.at(TokenKind::Case) { |
| 2772 | // test_err match_stmt_expected_case_block |
| 2773 | // match x: |
| 2774 | // x = 1 |
| 2775 | // match x: |
| 2776 | // match y: |
| 2777 | // case _: ... |
| 2778 | self.add_error( |
| 2779 | ParseErrorType::OtherError("Expected `case` block".to_string()), |
| 2780 | self.current_token_range(), |
| 2781 | ); |
| 2782 | return cases; |
| 2783 | } |
| 2784 | |
| 2785 | let mut progress = ParserProgress::default(); |
| 2786 | |
| 2787 | while self.at(TokenKind::Case) { |
| 2788 | progress.assert_progressing(self); |
| 2789 | cases.push(self.parse_match_case()); |
| 2790 | } |
| 2791 | |
| 2792 | cases |
| 2793 | } |
| 2794 | |
| 2795 | /// Parses a single match case block. |
| 2796 | /// |
no test coverage detected