https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations
(
&mut self,
min_precedence: u8,
)
| 2168 | // https://docs.python.org/3/reference/expressions.html#binary-arithmetic-operations |
| 2169 | // |
| 2170 | fn parse_binary_arithmetic_operation( |
| 2171 | &mut self, |
| 2172 | min_precedence: u8, |
| 2173 | ) -> Result<Expression, ParsingError> { |
| 2174 | let node = self.start_node(); |
| 2175 | let mut lhs = self.parse_unary_arithmetic_operation()?; |
| 2176 | while let Some((op, precedence, associativity)) = self.cur_kind().bin_op_precedence() { |
| 2177 | if precedence < min_precedence { |
| 2178 | break; |
| 2179 | } |
| 2180 | self.bump_any(); |
| 2181 | let next_precedence = match associativity { |
| 2182 | 0 => precedence + 1, |
| 2183 | 1 => precedence, |
| 2184 | _ => unreachable!(), |
| 2185 | }; |
| 2186 | let rhs = self.parse_binary_arithmetic_operation(next_precedence)?; |
| 2187 | lhs = Expression::BinOp(Box::new(BinOp { |
| 2188 | node: self.finish_node(node), |
| 2189 | op, |
| 2190 | left: lhs, |
| 2191 | right: rhs, |
| 2192 | })); |
| 2193 | } |
| 2194 | Ok(lhs) |
| 2195 | } |
| 2196 | |
| 2197 | // https://docs.python.org/3/reference/expressions.html#unary-arithmetic-and-bitwise-operations |
| 2198 | fn parse_unary_arithmetic_operation(&mut self) -> Result<Expression, ParsingError> { |
no test coverage detected