mirror of
https://github.com/storytold/gridcraft.git
synced 2026-12-01 18:26:05 -06:00
dax: document IN at the comparison tier (#2228)
This commit is contained in:
@@ -201,19 +201,20 @@ right, except `^`:
|
||||
|
||||
| Level | Operators | Associativity |
|
||||
| --- | --- | --- |
|
||||
| 1 | grouping `()`, function calls, `IN` | — (`IN` is an infix operator) |
|
||||
| 1 | grouping `()`, function calls | — |
|
||||
| 2 | `^` | right |
|
||||
| 3 | unary `+`, `-` | prefix |
|
||||
| 4 | `*`, `/` | left |
|
||||
| 5 | binary `+`, `-` | left |
|
||||
| 6 | `&` | left |
|
||||
| 7 | `=`, `==`, `<>`, `<`, `>`, `<=`, `>=` | left |
|
||||
| 7 | `=`, `==`, `<>`, `<`, `>`, `<=`, `>=`, `IN` | left |
|
||||
| 8 | `NOT` | prefix |
|
||||
| 9 | `&&` | left |
|
||||
| 10 | `\|\|` | left |
|
||||
|
||||
`=` coerces types at evaluation time; `==` is strict equality. This crate only records which
|
||||
operator was written. `IN` takes a list (`expr IN { v1, v2 }`) or a table expression
|
||||
operator was written. `IN` is a comparison at the same level as `=`, so `1 + 2 IN { 3 }` parses as
|
||||
`(1 + 2) IN { 3 }`, and it takes a list (`expr IN { v1, v2 }`) or a table expression
|
||||
(`expr IN VALUES(T[Col])`).
|
||||
|
||||
Excel evaluates `2^3^2` as `512` (`2^(3^2)`), so `^` is right-associative even though the generic
|
||||
|
||||
@@ -214,8 +214,8 @@ impl BinaryOp {
|
||||
}
|
||||
|
||||
/// Binding power, higher binds tighter. The values encode the ten precedence levels
|
||||
/// from DAX Guide: parentheses/calls/`IN`, `^`, unary sign, `* /`, `+ -`, `&`,
|
||||
/// comparisons, `NOT`, `&&`, `||`.
|
||||
/// from the operator table: parentheses/calls, `^`, unary sign, `* /`, `+ -`, `&`,
|
||||
/// comparisons (including `IN`), `NOT`, `&&`, `||`.
|
||||
pub const fn precedence(self) -> u8 {
|
||||
match self {
|
||||
BinaryOp::Pow => 90,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Pratt parser: tokens → [`Expr`] / [`Query`].
|
||||
//!
|
||||
//! Binding powers encode the DAX operator table from <https://dax.guide/operators/> (tighter
|
||||
//! binds first): parentheses, function calls and `IN`; `^`; unary `+`/`-`; `*`/`/`; binary
|
||||
//! `+`/`-`; `&`; comparisons; `NOT`; `&&`; `||`. All operators are left-associative except
|
||||
//! `^`, which Excel evaluates right-associatively (`2^3^2` is 512).
|
||||
//! Binding powers encode the operator table (tighter binds first): parentheses and function
|
||||
//! calls; `^`; unary `+`/`-`; `*`/`/`; binary `+`/`-`; `&`; comparisons, which include `IN`; `NOT`;
|
||||
//! `&&`; `||`. All operators are left-associative except `^`, which Excel evaluates
|
||||
//! right-associatively (`2^3^2` is 512).
|
||||
|
||||
use crate::ast::{
|
||||
Axis, AxisGroup, AxisKind, AxisOrderItem, BinaryOp, Call, ColumnDef, Define, Definition, Evaluate, Expr, ExprKind, FunctionDef, FunctionParam,
|
||||
|
||||
Reference in New Issue
Block a user