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:2711–2735  ·  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

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

Callers 1

parse_lhs_expressionMethod · 0.80

Tested by

no test coverage detected