Entry point to start parsing a pattern. See:
(&mut self)
| 67 | /// |
| 68 | /// See: <https://docs.python.org/3/reference/compound_stmts.html#grammar-token-python-grammar-patterns> |
| 69 | pub(super) fn parse_match_patterns(&mut self) -> Pattern { |
| 70 | let start = self.node_start(); |
| 71 | |
| 72 | // We don't yet know if it's a sequence pattern or a single pattern, so |
| 73 | // we need to allow star pattern here. |
| 74 | let pattern = self.parse_match_pattern(AllowStarPattern::Yes); |
| 75 | |
| 76 | if self.at(TokenKind::Comma) { |
| 77 | Pattern::MatchSequence(self.parse_sequence_match_pattern(pattern, start, None)) |
| 78 | } else { |
| 79 | // We know it's not a sequence pattern now, so check for star pattern usage. |
| 80 | if pattern.is_match_star() { |
| 81 | self.add_error(ParseErrorType::InvalidStarPatternUsage, &pattern); |
| 82 | } |
| 83 | pattern |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /// Parses an `or_pattern` or an `as_pattern`. |
| 88 | /// |
no test coverage detected