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,
)
| 747 | /// |
| 748 | /// This method does nothing if the current token is not a candidate for a postfix expression. |
| 749 | pub(super) fn parse_postfix_expression( |
| 750 | &mut self, |
| 751 | mut lhs: Expr, |
| 752 | start: TextSize, |
| 753 | context: ExpressionContext, |
| 754 | ) -> Expr { |
| 755 | loop { |
| 756 | lhs = match self.current_token_kind() { |
| 757 | TokenKind::Lpar => { |
| 758 | if self.tokens.nesting() > self.max_nesting_depth { |
| 759 | self.report_recursion_limit_exceeded(self.current_token_range()); |
| 760 | break lhs; |
| 761 | } |
| 762 | Expr::Call(self.parse_call_expression(lhs, start)) |
| 763 | } |
| 764 | TokenKind::Lsqb => { |
| 765 | if self.tokens.nesting() > self.max_nesting_depth { |
| 766 | self.report_recursion_limit_exceeded(self.current_token_range()); |
| 767 | break lhs; |
| 768 | } |
| 769 | Expr::Subscript(self.parse_subscript_expression(lhs, start)) |
| 770 | } |
| 771 | TokenKind::Dot => { |
| 772 | Expr::Attribute(self.parse_attribute_expression(lhs, start, context)) |
| 773 | } |
| 774 | _ => break lhs, |
| 775 | }; |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | /// Parse a call expression. |
| 780 | /// |
no test coverage detected