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