(expr: &pr::ExprKind)
| 246 | } |
| 247 | |
| 248 | fn binding_strength(expr: &pr::ExprKind) -> u8 { |
| 249 | match expr { |
| 250 | // For example, if it's an Ident, it's basically infinite — a simple |
| 251 | // ident never needs parentheses around it. |
| 252 | pr::ExprKind::Ident(_) => 100, |
| 253 | |
| 254 | // Stronger than a range, since `-1..2` is `(-1)..2` |
| 255 | // Stronger than binary op, since `-x == y` is `(-x) == y` |
| 256 | // Stronger than a func call, since `exists !y` is `exists (!y)` |
| 257 | pr::ExprKind::Unary(..) => 20, |
| 258 | |
| 259 | pr::ExprKind::Range(_) => 19, |
| 260 | |
| 261 | pr::ExprKind::Binary(pr::BinaryExpr { op, .. }) => match op { |
| 262 | pr::BinOp::Pow => 19, |
| 263 | pr::BinOp::Mul | pr::BinOp::DivInt | pr::BinOp::DivFloat | pr::BinOp::Mod => 18, |
| 264 | pr::BinOp::Add | pr::BinOp::Sub => 17, |
| 265 | pr::BinOp::Eq |
| 266 | | pr::BinOp::Ne |
| 267 | | pr::BinOp::Gt |
| 268 | | pr::BinOp::Lt |
| 269 | | pr::BinOp::Gte |
| 270 | | pr::BinOp::Lte |
| 271 | | pr::BinOp::RegexSearch => 16, |
| 272 | pr::BinOp::Coalesce => 15, |
| 273 | pr::BinOp::And => 14, |
| 274 | pr::BinOp::Or => 13, |
| 275 | }, |
| 276 | |
| 277 | // Weaker than a child assign, since `select x = 1` |
| 278 | // Weaker than a binary operator, since `filter x == 1` |
| 279 | pr::ExprKind::FuncCall(_) => 10, |
| 280 | pr::ExprKind::Func(_) => 7, |
| 281 | |
| 282 | // other nodes should not contain any inner exprs |
| 283 | _ => 100, |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | fn associativity(expr: &pr::ExprKind) -> super::Position { |
| 288 | match expr { |
no outgoing calls
no test coverage detected