Parses a unary expression. This includes the unary arithmetic `+` and `-`, bitwise `~`, and the boolean `not` operators. # Panics If the parser isn't positioned at any of the unary operators. See:
(
&mut self,
op: UnaryOp,
context: ExpressionContext,
)
| 1110 | /// |
| 1111 | /// See: <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations> |
| 1112 | pub(super) fn parse_unary_expression( |
| 1113 | &mut self, |
| 1114 | op: UnaryOp, |
| 1115 | context: ExpressionContext, |
| 1116 | ) -> ast::ExprUnaryOp { |
| 1117 | let start = self.node_start(); |
| 1118 | self.bump(TokenKind::from(op)); |
| 1119 | |
| 1120 | let operand = self.parse_binary_expression_or_higher(OperatorPrecedence::from(op), context); |
| 1121 | |
| 1122 | ast::ExprUnaryOp { |
| 1123 | op, |
| 1124 | operand: Box::new(operand.expr), |
| 1125 | range: self.node_range(start), |
| 1126 | node_index: AtomicNodeIndex::NONE, |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | /// Parses an attribute expression. |
| 1131 | /// |
no test coverage detected