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,
)
| 1190 | /// |
| 1191 | /// See: <https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations> |
| 1192 | pub(super) fn parse_unary_expression( |
| 1193 | &mut self, |
| 1194 | op: UnaryOp, |
| 1195 | context: ExpressionContext, |
| 1196 | ) -> ast::ExprUnaryOp { |
| 1197 | let start = self.node_start(); |
| 1198 | self.bump(TokenKind::from(op)); |
| 1199 | |
| 1200 | let operand = self.parse_binary_expression_or_higher(OperatorPrecedence::from(op), context); |
| 1201 | |
| 1202 | ast::ExprUnaryOp { |
| 1203 | op, |
| 1204 | operand: Box::new(operand.expr), |
| 1205 | range: self.node_range(start), |
| 1206 | node_index: AtomicNodeIndex::NONE, |
| 1207 | } |
| 1208 | } |
| 1209 | |
| 1210 | /// Parses an attribute expression. |
| 1211 | /// |
no test coverage detected