Sequences of ``operator characters'', such as <=> or !!, are read as a single token from the infix-symbol or prefix-symbol class:
infix-symbol:
(= | < | > | @ | ^ | | | & | ~ | + | - | * | / | $ | %) {operator-char}
prefix-symbol:
(! | ?) {operator-char}
operator-char:
! | $ | % | & | * | + | - | . | / | : | ; | < | = | > | ? | @ | ^ | | | ~
Tokens from these two classes generalize the built-in infix and prefix operators described in chapter 3:
expr:
...
| prefix-symbol expr
| expr infix-symbol expr
variable:
...
| prefix prefix-symbol
| prefix infix-symbol
No #infix directive (section 4.10) is needed to give infix symbols their infix status. The precedences and associativities of infix symbols in expressions are determined by their first character(s): symbols beginning with ** have highest precedence (exponentiation), followed by symbols beginning with *, / or % (multiplication), then + and - (addition), then @ and ^ (concatenation), then all others symbols (comparisons). The updated precedence table for expressions is shown below. We write ``*...'' to mean ``any infix symbol starting with *''.
| Construction or operator | Associativity |
|---|---|
| !... ?... | -- |
| . .( .[ | -- |
| function application | left |
| constructor application | -- |
| - -. (prefix) | -- |
| **... | right |
| *... /... %... mod | left |
| +... -... | left |
| :: | right |
| @... ^... | right |
| comparisons (= == < etc.), all other infix symbols | left |
| not | -- |
| & && | left |
| or || | left |
| , | -- |
| <- := | right |
| if | -- |
| ; | right |
| let match fun function try | -- |
let prefix infix-symbol = expr
or let prefix prefix-symbol = expr binding.