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

Method parse_postfix_expression

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

Parses a postfix expression in a loop until there are no postfix expressions left to parse. For a given left-hand side, a postfix expression can begin with either `(` for a call expression, `[` for a subscript expression, or `.` for an attribute expression. This method does nothing if the current token is not a candidate for a postfix expression.

(
        &mut self,
        mut lhs: Expr,
        start: TextSize,
        context: ExpressionContext,
    )

Source from the content-addressed store, hash-verified

680 ///
681 /// This method does nothing if the current token is not a candidate for a postfix expression.
682 fn parse_postfix_expression(
683 &mut self,
684 mut lhs: Expr,
685 start: TextSize,
686 context: ExpressionContext,
687 ) -> Expr {
688 loop {
689 lhs = match self.current_token_kind() {
690 TokenKind::Lpar => Expr::Call(self.parse_call_expression(lhs, start)),
691 TokenKind::Lsqb => Expr::Subscript(self.parse_subscript_expression(lhs, start)),
692 TokenKind::Dot => {
693 Expr::Attribute(self.parse_attribute_expression(lhs, start, context))
694 }
695 _ => break lhs,
696 };
697 }
698 }
699
700 /// Parse a call expression.
701 ///

Callers 1

parse_lhs_expressionMethod · 0.80

Calls 4

current_token_kindMethod · 0.80
parse_call_expressionMethod · 0.80

Tested by

no test coverage detected