MCPcopy Create free account
hub / github.com/astral-sh/ruff / parse_starred_expression

Method parse_starred_expression

crates/ruff_python_parser/src/parser/expression.rs:2703–2727  ·  view source on GitHub ↗

Parses a starred expression with the given precedence. The expression is parsed with the highest precedence. If the precedence of the parsed expression is lower than the given precedence, an error is reported. For example, if the given precedence is [`StarredExpressionPrecedence::BitOr`], the comparison expression is not allowed. Refer to the [Python grammar] for more information. # Panics If

(&mut self, context: ExpressionContext)

Source from the content-addressed store, hash-verified

2701 ///
2702 /// [Python grammar]: https://docs.python.org/3/reference/grammar.html
2703 fn parse_starred_expression(&mut self, context: ExpressionContext) -> ast::ExprStarred {
2704 let start = self.node_start();
2705 self.bump(TokenKind::Star);
2706
2707 let parsed_expr = match context.starred_expression_precedence() {
2708 StarredExpressionPrecedence::Conditional => self
2709 .parse_conditional_expression_or_higher_impl(
2710 // test_err starred_starred_expression
2711 // print(*
2712 // *[])
2713 // print(* *[])
2714 context.disallow_starred_expressions(),
2715 ),
2716 StarredExpressionPrecedence::BitwiseOr => {
2717 self.parse_expression_with_bitwise_or_precedence()
2718 }
2719 };
2720
2721 ast::ExprStarred {
2722 value: Box::new(parsed_expr.expr),
2723 ctx: ExprContext::Load,
2724 range: self.node_range(start),
2725 node_index: AtomicNodeIndex::NONE,
2726 }
2727 }
2728
2729 /// Parses an `await` expression.
2730 ///

Callers 1

parse_lhs_expressionMethod · 0.80

Tested by

no test coverage detected