Parses a sequence of clauses. The parser only continues for as long as it sees the token indicating the start of the specific clause. Unlike [`Parser::parse_list`], this method does not perform error recovery when the next token is not a list terminator or the start of a list element. The special method is necessary because Python uses indentation over explicit delimiters to indicate the end of
(&mut self, clause: Clause, mut parse_clause: impl FnMut(&mut Parser<'src>))
| 4038 | /// `Else`) to the recovery context so that expression recovery stops when it encounters an |
| 4039 | /// `else` token. |
| 4040 | fn parse_clauses(&mut self, clause: Clause, mut parse_clause: impl FnMut(&mut Parser<'src>)) { |
| 4041 | let mut progress = ParserProgress::default(); |
| 4042 | |
| 4043 | let recovery_kind = match clause { |
| 4044 | Clause::ElIf => RecoveryContextKind::Elif, |
| 4045 | Clause::Except => RecoveryContextKind::Except, |
| 4046 | _ => unreachable!("Clause is not supported"), |
| 4047 | }; |
| 4048 | |
| 4049 | let saved_context = self.recovery_context; |
| 4050 | self.recovery_context = self |
| 4051 | .recovery_context |
| 4052 | .union(RecoveryContext::from_kind(recovery_kind)); |
| 4053 | |
| 4054 | while recovery_kind.is_list_element(self) { |
| 4055 | progress.assert_progressing(self); |
| 4056 | |
| 4057 | parse_clause(self); |
| 4058 | } |
| 4059 | |
| 4060 | self.recovery_context = saved_context; |
| 4061 | } |
| 4062 | } |
| 4063 | |
| 4064 | #[derive(Copy, Clone)] |
no test coverage detected