(self, p: &Parser)
| 1422 | } |
| 1423 | |
| 1424 | fn create_error(self, p: &Parser) -> ParseErrorType { |
| 1425 | match self { |
| 1426 | RecoveryContextKind::ModuleStatements | RecoveryContextKind::BlockStatements => { |
| 1427 | if p.at(TokenKind::Indent) { |
| 1428 | ParseErrorType::UnexpectedIndentation |
| 1429 | } else { |
| 1430 | ParseErrorType::OtherError("Expected a statement".to_string()) |
| 1431 | } |
| 1432 | } |
| 1433 | RecoveryContextKind::Elif => ParseErrorType::OtherError( |
| 1434 | "Expected an `elif` or `else` clause, or the end of the `if` statement." |
| 1435 | .to_string(), |
| 1436 | ), |
| 1437 | RecoveryContextKind::Except => ParseErrorType::OtherError( |
| 1438 | "Expected an `except` or `finally` clause or the end of the `try` statement." |
| 1439 | .to_string(), |
| 1440 | ), |
| 1441 | RecoveryContextKind::AssignmentTargets => { |
| 1442 | if p.current_token_kind().is_keyword() { |
| 1443 | ParseErrorType::OtherError( |
| 1444 | "The keyword is not allowed as a variable declaration name".to_string(), |
| 1445 | ) |
| 1446 | } else { |
| 1447 | ParseErrorType::OtherError("Expected an assignment target".to_string()) |
| 1448 | } |
| 1449 | } |
| 1450 | RecoveryContextKind::TypeParams => ParseErrorType::OtherError( |
| 1451 | "Expected a type parameter or the end of the type parameter list".to_string(), |
| 1452 | ), |
| 1453 | RecoveryContextKind::ImportFromAsNames(parenthesized) => { |
| 1454 | if parenthesized.is_yes() { |
| 1455 | ParseErrorType::OtherError("Expected an import name or a ')'".to_string()) |
| 1456 | } else { |
| 1457 | ParseErrorType::OtherError("Expected an import name".to_string()) |
| 1458 | } |
| 1459 | } |
| 1460 | RecoveryContextKind::ImportNames => { |
| 1461 | ParseErrorType::OtherError("Expected an import name".to_string()) |
| 1462 | } |
| 1463 | RecoveryContextKind::Slices => ParseErrorType::OtherError( |
| 1464 | "Expected an expression or the end of the slice list".to_string(), |
| 1465 | ), |
| 1466 | RecoveryContextKind::ListElements => { |
| 1467 | ParseErrorType::OtherError("Expected an expression or a ']'".to_string()) |
| 1468 | } |
| 1469 | RecoveryContextKind::SetElements | RecoveryContextKind::DictElements => { |
| 1470 | ParseErrorType::OtherError("Expected an expression or a '}'".to_string()) |
| 1471 | } |
| 1472 | RecoveryContextKind::TupleElements(parenthesized) => { |
| 1473 | if parenthesized.is_yes() { |
| 1474 | ParseErrorType::OtherError("Expected an expression or a ')'".to_string()) |
| 1475 | } else { |
| 1476 | ParseErrorType::OtherError("Expected an expression".to_string()) |
| 1477 | } |
| 1478 | } |
| 1479 | RecoveryContextKind::SequenceMatchPattern(_) => ParseErrorType::OtherError( |
| 1480 | "Expected a pattern or the end of the sequence pattern".to_string(), |
| 1481 | ), |
no test coverage detected