Operator precedence

When an expression contains several operators, precedence decides which operators apply first. The table lists the operators from the highest precedence to the lowest. Operators on the same level have the same precedence, and the last column shows how EFX groups several of them in a row. Parentheses change the order that precedence sets (see Parentheses and precedence).

Precedence table

Level Operators Grouping

1

parentheses ( … ); function calls; and what follows a reference or another expression: a predicate […], an index [at …], an attribute /@<name>, a context override :: and the properties :rawValue, :preferredLanguage and :preferredLanguageText

from left to right

2

* (multiplication), / (division), % (remainder)

from left to right

3

+ (addition), - (subtraction)

from left to right

4

the conditions, each applying before the ones listed after it: in, not in; is unique in, is not unique in; is empty, is not empty; has duplicates, has no duplicates; like, not like; is present, is not present

from left to right

5

==, !=, <, <=, >, >=

from left to right

6

and

from left to right

7

or

from left to right

8

if … then … else; for … return; every … satisfies; some … satisfies

the last part extends as far to the right as possible

Some consequences of the table:

  • 1 + 2 * 3 is 1 + (2 * 3), and 10 - 2 - 3 is (10 - 2) - 3.

  • BT-00-Number + 1 in [2, 3] is (BT-00-Number + 1) in [2, 3].

  • BT-00-Indicator == BT-00-Text in ['a', 'b'] is BT-00-Indicator == (BT-00-Text in ['a', 'b']): a condition applies before a comparison.

  • 1 < 2 == TRUE is (1 < 2) == TRUE.

  • TRUE or FALSE and FALSE is TRUE or (FALSE and FALSE).

  • every … satisfies $n > 0 or BT-00-Text is present: the or belongs to the condition after satisfies.

  • if TRUE then 1 else 2 + 3 is if TRUE then 1 else (2 + 3).

EFX has no unary minus, that is, no minus sign that you can put before any expression to change its sign. A minus sign before a number literal or a duration literal is part of the literal, as in -3 or -P1D. EFX has no negation operator either: not(…) is a function, and the word not in not in, not like and is not … is part of those operators.