(self, p: &Parser)
| 1148 | } |
| 1149 | |
| 1150 | fn create_error(self, p: &Parser) -> ParseErrorType { |
| 1151 | match self { |
| 1152 | RecoveryContextKind::ModuleStatements | RecoveryContextKind::BlockStatements => { |
| 1153 | if p.at(TokenKind::Indent) { |
| 1154 | ParseErrorType::UnexpectedIndentation |
| 1155 | } else { |
| 1156 | ParseErrorType::OtherError("Expected a statement".to_string()) |
| 1157 | } |
| 1158 | } |
| 1159 | RecoveryContextKind::Elif => ParseErrorType::OtherError( |
| 1160 | "Expected an `elif` or `else` clause, or the end of the `if` statement." |
| 1161 | .to_string(), |
| 1162 | ), |
| 1163 | RecoveryContextKind::Except => ParseErrorType::OtherError( |
| 1164 | "Expected an `except` or `finally` clause or the end of the `try` statement." |
| 1165 | .to_string(), |
| 1166 | ), |
| 1167 | RecoveryContextKind::AssignmentTargets => { |
| 1168 | if p.current_token_kind().is_keyword() { |
| 1169 | ParseErrorType::OtherError( |
| 1170 | "The keyword is not allowed as a variable declaration name".to_string(), |
| 1171 | ) |
| 1172 | } else { |
| 1173 | ParseErrorType::OtherError("Expected an assignment target".to_string()) |
| 1174 | } |
| 1175 | } |
| 1176 | RecoveryContextKind::TypeParams => ParseErrorType::OtherError( |
| 1177 | "Expected a type parameter or the end of the type parameter list".to_string(), |
| 1178 | ), |
| 1179 | RecoveryContextKind::ImportFromAsNames(parenthesized) => { |
| 1180 | if parenthesized.is_yes() { |
| 1181 | ParseErrorType::OtherError("Expected an import name or a ')'".to_string()) |
| 1182 | } else { |
| 1183 | ParseErrorType::OtherError("Expected an import name".to_string()) |
| 1184 | } |
| 1185 | } |
| 1186 | RecoveryContextKind::ImportNames => { |
| 1187 | ParseErrorType::OtherError("Expected an import name".to_string()) |
| 1188 | } |
| 1189 | RecoveryContextKind::Slices => ParseErrorType::OtherError( |
| 1190 | "Expected an expression or the end of the slice list".to_string(), |
| 1191 | ), |
| 1192 | RecoveryContextKind::ListElements => { |
| 1193 | ParseErrorType::OtherError("Expected an expression or a ']'".to_string()) |
| 1194 | } |
| 1195 | RecoveryContextKind::SetElements | RecoveryContextKind::DictElements => { |
| 1196 | ParseErrorType::OtherError("Expected an expression or a '}'".to_string()) |
| 1197 | } |
| 1198 | RecoveryContextKind::TupleElements(parenthesized) => { |
| 1199 | if parenthesized.is_yes() { |
| 1200 | ParseErrorType::OtherError("Expected an expression or a ')'".to_string()) |
| 1201 | } else { |
| 1202 | ParseErrorType::OtherError("Expected an expression".to_string()) |
| 1203 | } |
| 1204 | } |
| 1205 | RecoveryContextKind::SequenceMatchPattern(_) => ParseErrorType::OtherError( |
| 1206 | "Expected a pattern or the end of the sequence pattern".to_string(), |
| 1207 | ), |
no test coverage detected