Parses an `or_pattern` or an `as_pattern`. See:
(&mut self, allow_star_pattern: AllowStarPattern)
| 88 | /// |
| 89 | /// See: <https://docs.python.org/3/reference/compound_stmts.html#grammar-token-python-grammar-pattern> |
| 90 | fn parse_match_pattern(&mut self, allow_star_pattern: AllowStarPattern) -> Pattern { |
| 91 | if let Some(result) = |
| 92 | self.with_recursion(|parser| parser.parse_match_pattern_inner(allow_star_pattern)) |
| 93 | { |
| 94 | result |
| 95 | } else { |
| 96 | let range = self.missing_node_range(); |
| 97 | self.report_recursion_limit_exceeded(self.current_token_range()); |
| 98 | let invalid_node = Expr::Name(ast::ExprName { |
| 99 | range, |
| 100 | id: Name::empty(), |
| 101 | ctx: ExprContext::Invalid, |
| 102 | node_index: AtomicNodeIndex::NONE, |
| 103 | }); |
| 104 | Pattern::MatchValue(ast::PatternMatchValue { |
| 105 | range: invalid_node.range(), |
| 106 | value: Box::new(invalid_node), |
| 107 | node_index: AtomicNodeIndex::NONE, |
| 108 | }) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | fn parse_match_pattern_inner(&mut self, allow_star_pattern: AllowStarPattern) -> Pattern { |
| 113 | let start = self.node_start(); |
no test coverage detected