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
:
expr:
...
| prefix-symbol expr
| expr infix-symbol expr
variable:
...
| prefix prefix-symbol
| prefix infix-symbol
No #infix directive (section
) 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 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 | right |
| 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 | -- |
and
for a
description of their behavior). The others are initially unbound and
must be bound before use, with a let prefix infix-symbol = expr
or let prefix prefix-symbol = expr binding.