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