Expression syntax

<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>)* "]"
  ;

Operator Precedence and associativity

Operators with the lowest precedence MUST be evaluated before operators with a higher precedence.

Expressions within parentheses MUST be evaluated first.

PrecedenceOperatorDescriptionAssociativity
1a<>Generic specializationLeft to Right →
a()Function call
.Member access
2~aBitwise NOTRight to Left ←
not aLogical NOT
-aUnary minus
3a**bExponentLeft to Right →
4a*bMultiplication
a/bDivision
a%bModulo
5a+bAddition
a-bSubstraction
6a<>bString concatenation
7a<<bBitwise left shift
a>>bBitwise right shift
8a<bLess than comparison
a<=bLess than or equal comparison
a>=bGreater than or equal comparison
a>bGreater than comparison
9a=bEquality comparison
a!=bInequality comparison
10a in bInclusion comparison
a not in bExclusion comparison
11a&bBitwise AND
12a^bBitwise XOR
13a|bBitwise OR
14a and bLogical AND
15a or bLogical OR
16throw aException throwingRight to Left ←
17|>PipelineLeft to Right →
18isType membership inclusion
is notType membership exclusion
19:=Pattern matching