Perun2 operator precedence applies similar rules as used in majority of programming languages. A noticeable difference is inclusion of several new syntax structures such as filters. Because brackets have higher precedence than any other data type expression element, they should be used to enforce a desired precedence and explain possible ambiguity. All operators are associated left-to-right.
Precedence | Name | Operator / Expression | ||
---|---|---|---|---|
19 | Command brackets | { ... } | ... { ... } | |
18 | Command separator | ... ; ... | ||
17 | Command | print ... | select ... | copy ... to ... |
Variable assignment | ... = ... | |||
Variable modification | ... += ... | ... -= ... | ... *= ... | |
16 | Brackets | ( ... ) | ||
15 | Element at index | ... [ ... ] | ||
14 | Function | ... () | ... ( ... ) | ... ( ... , ... ) |
13 | Filter | ... where ... | ... order by ... | ... limit ... |
12 | Boolean binary operator | ... and ... | ... or ... | ... xor ... |
11 | Boolean negation | not ... | ||
10 | Like, In, Resembles, Between, Regexp | ... like ... | ... not like ... | ... in ... |
9 | Comparison | ... = ... | ... == ... | ... >= ... |
8 | Collection separator | ... , ... | ||
7 | Addition | ... + ... | ||
Subtraction | ... - ... | |||
6 | Multiplication | ... * ... | ||
Division | ... / ... | |||
Modulo | ... % ... | |||
5 | Number/period negation | - ... | ||
4 | Binary condition | ... ? ... | ||
3 | Ternary condition | ... ? ... : ... | ||
2 | Member access | ... . ... | ||
Period constant | ... ... | |||
Time constant | ... ... ... | ... , ... : ... | ... , ... : ... : ... | |
1 | Basic unit | 'string' | 1500.31 | variable |