Operators
Operators
Operators
<proposition> :=
| <proposition-let>
| <proposition-expression>
;
<proposition-expression> :=
<expression>
;
<expression> :=
| "(" <expression> ")"
| <expression-term>
| <expression-binop>
| <expression-unop>
| <expression-pattern-match>
| <expression-typecheck>
| <expression-generic-specialization>
| <expression-function-call>
| ...
;
<expression-term> :=
| <expression-symbol>
| <value-literal>
| <tuple-literal>
| <struct-literal>
| <list-literal>
| <match-block>
| <cond-block>
| ...
;
<expression-binop> :=
<expression> <binary-operator> <expression>
;
<expression-unop> :=
<unary-operator> <expression>
;
<expression-pattern-match> :=
<pattern> ":=" <expression>
;
<expression-typecheck> :=
| <expression> "is" <typeref>
| <expression> "is not" <typeref>
;
<expression-generic-specialization> :=
<expression> "<" <typeref> ("," <typeref>)* ">"
;
<expression-function-call> :=
<expression> "(" <expression> ("," <expression>)* ")"
;
<expression-symbol> :=
<identifier> ("::" <identifier>)*
;
<value-literal> :=
<literal>
;
<tuple-literal> :=
"(" <expression> ("," <expression>)* ")"
;
<struct-literal> :=
"{" <struct-literal-member> ("," <struct-literal-member>)* "}"
;
<struct-literal-member> :=
<identifier> ":" <expression>
;
<list-literal> :=
"[" <expression> ("," <expression>)* "]"
;
Operators with the lowest precedence MUST be evaluated before operators with a higher precedence.
Expressions within parentheses MUST be evaluated first.
Precedence | Operator | Description | Associativity |
---|---|---|---|
1 | a<> | Generic specialization | Left to Right → |
a() | Function call | ||
. | Member access | ||
2 | ~a | Bitwise NOT | Right to Left ← |
not a | Logical NOT | ||
-a | Unary minus | ||
3 | a**b | Exponent | Left to Right → |
4 | a*b | Multiplication | |
a/b | Division | ||
a%b | Modulo | ||
5 | a+b | Addition | |
a-b | Substraction | ||
6 | a<>b | String concatenation | |
7 | a<<b | Bitwise left shift | |
a>>b | Bitwise right shift | ||
8 | a<b | Less than comparison | |
a<=b | Less than or equal comparison | ||
a>=b | Greater than or equal comparison | ||
a>b | Greater than comparison | ||
9 | a=b | Equality comparison | |
a!=b | Inequality comparison | ||
10 | a in b | Inclusion comparison | |
a not in b | Exclusion comparison | ||
11 | a&b | Bitwise AND | |
12 | a^b | Bitwise XOR | |
13 | a|b | Bitwise OR | |
14 | a and b | Logical AND | |
15 | a or b | Logical OR | |
16 | throw a | Exception throwing | Right to Left ← |
17 | |> | Pipeline | Left to Right → |
18 | is | Type membership inclusion | |
is not | Type membership exclusion | ||
19 | := | Pattern matching |