Operators, precedence, and the two lowerings.
Generated from the language definition for language 1.0.
Expressions
One grammar, two lowerings: a record-local position (a guard, a validation, a browser gate) lowers to JSONLogic; a set-level position (a query, a related list, a rollup, a stat) lowers to a DAL statement. Comparisons do not chain; = is accepted and printed as ==.
Binary operators
| Operator | Precedence | JSONLogic | DAL |
|---|---|---|---|
or | 1 (or) | or | Or |
and | 2 (and) | and | And |
== | 4 (comparison) | == | Eq |
!= | 4 (comparison) | != | Ne |
< | 4 (comparison) | < | Lt |
<= | 4 (comparison) | <= | Le |
> | 4 (comparison) | > | Gt |
>= | 4 (comparison) | >= | Ge |
like | 4 (comparison) | not available (no pattern match) | Like |
+ | 5 (additive) | + | not available (no arithmetic) |
- | 5 (additive) | - | not available (no arithmetic) |
* | 6 (multiplicative) | * | not available (no arithmetic) |
/ | 6 (multiplicative) | / | not available (no arithmetic) |
Other forms
not x: logical negation-x: arithmetic negationx is null: null test (x is not nullfor the complement)x in [a, b]: membership in a list of literalsx in (select …): membership in a subquery (set-level only)exists (select …): a non-empty subquery (set-level only)a.b: a field, or one level ofreftraversalthis: the current record in a set-level position;this.fieldreads one of its fieldsme: the current user (set-level only)(x): grouping; parentheses survive round trips where precedence needs them
Functions
Set-level only: JSONLogic has no lower, upper, length or coalesce, and its substr counts from zero where the DAL's counts from one, so a record-local position refuses them rather than promise one meaning in two targets.
| Function | Arguments | DAL |
|---|---|---|
lower | 1 | Lower |
upper | 1 | Upper |
coalesce | 2 or more | Coalesce |
length | 1 | Length |
substr | 2 to 3 | Substr |
Aggregates
agg(Entity[.field] [where expr]); in a guard, count(…) op n and sum(…) op n compile to the engine's related-record guards.
| Aggregate | DAL |
|---|---|
count | Count |
sum | Sum |
avg | Avg |
min | Min |
max | Max |
JSONLogic operators the compiler may emit
A jsonlogic { … } literal may use any of them, and the sugar emits the ones its operators map to.
==, !=, ===, !==, !, !!, <, <=, >, >=, +, -, *, /, %, max, min, merge, in, cat, substr, log, var, missing, missing_some, if, ?:, or, and, map, filter, reduce, all, some, none
DAL vocabulary
- Binary operators:
Eq,Ne,Lt,Le,Gt,Ge,And,Or,In,NotIn,Like - Unary operators:
Not,IsNull,IsNotNull - Functions:
Lower,Upper,Coalesce,Length,Substr - Aggregates:
Count,Sum,Avg,Min,Max - Built-in sources:
jobs(Jobs),event_log(EventLog),fsm_schemas(FsmSchemas)