Parses a list of match case blocks.
(&mut self)
| 2732 | |
| 2733 | /// Parses a list of match case blocks. |
| 2734 | fn parse_match_case_blocks(&mut self) -> Vec<ast::MatchCase> { |
| 2735 | let mut cases = vec![]; |
| 2736 | |
| 2737 | if !self.at(TokenKind::Case) { |
| 2738 | // test_err match_stmt_expected_case_block |
| 2739 | // match x: |
| 2740 | // x = 1 |
| 2741 | // match x: |
| 2742 | // match y: |
| 2743 | // case _: ... |
| 2744 | self.add_error( |
| 2745 | ParseErrorType::OtherError("Expected `case` block".to_string()), |
| 2746 | self.current_token_range(), |
| 2747 | ); |
| 2748 | return cases; |
| 2749 | } |
| 2750 | |
| 2751 | let mut progress = ParserProgress::default(); |
| 2752 | |
| 2753 | while self.at(TokenKind::Case) { |
| 2754 | progress.assert_progressing(self); |
| 2755 | cases.push(self.parse_match_case()); |
| 2756 | } |
| 2757 | |
| 2758 | cases |
| 2759 | } |
| 2760 | |
| 2761 | /// Parses a single match case block. |
| 2762 | /// |
no test coverage detected