## 10.3. Precedence, Fixity, and Associativity

Precedence rules specify the order in which parts of an expression are parsed, in absence of parenthesis. For example, in `1 + 2 * 3`, Orc's precedence rules prescribe that the multiplication be parsed as a sub-expression of the addition. Operators or combinators listed in the table below with higher precedence will be parsed in preference to lower precedence operations or combinators.

Fixity specifies the relative position of an operator and it operands. For example, `+` is infix, so the `+` operator is written in between its operands. However, `?` is postfix, so it is written after its operand.

Associativity specifies the grouping of a series of infix operator (or combinator) expressions, in absence of parenthesis. For example, division is left associative, so `40 / 4 / 2` is grouped as `(40 / 4) / 2` which is 5. It is not `40 / (4 / 2)` = 20. Similarly, the sequential combinator is right associative, so `e >x> f >y> g` is equivalent to `e >x> (f >y> g)`.

Table 10.1. Orc Combinator/Operator Precedence, Fixity, and Associativity

Precedence LevelNameSymbolFixityAssociativity
13Call` () `Postfix--
Dot Access` . `Postfix--
Dereference` ? `Postfix--
12Arithmetic Negation` - `Prefix--
Negation (Logical Complement)` ~ `Prefix--
11Exponentiation` ** `InfixRight
10Multiplication` * `InfixLeft
Division` / `InfixLeft
Modulus` % `InfixLeft
9Addition/Concatenation` + `InfixLeft
Subtraction` - `InfixLeft
8List Construction` : `InfixRight
7Equal To` = `InfixNone
Not Equal To` /= `InfixNone
Less Than` <: `InfixNone
Greater Than` :> `InfixNone
Less Than or Equal To` <= `InfixNone
Greater Than or Equal To` >= `InfixNone
6Logical OR` || `InfixLeft
Logical AND` && `InfixLeft
5Assignment` := `InfixNone
4Sequential` >``P``> `InfixRight
3Parallel` | `InfixLeft
2Pruning` <``P``< `InfixLeft
1Otherwise` ; `InfixLeft
0Type Information` :: `InfixLeft
Type Override` :!: `InfixLeft
Closure`lambda`Prefix--
Conditional`if then else`Prefix--
Declaration`val, def, import, include, type`Prefix--