Operators

Nim allows user defined operators. An operator is any combination of the following characters:

  1. = + - * / < >
  2. @ $ ~ & % |
  3. ! ? ^ . : \

(The grammar uses the terminal OPR to refer to operator symbols as defined here.)

These keywords are also operators: and or not xor shl shr div mod in notin is isnot of as from.

. =, :, :: are not available as general operators; they are used for other notational purposes.

*: is as a special case treated as the two tokens * and : (to support var v*: T).

The not keyword is always a unary operator, a not b is parsed as a(not b), not as (a) not (b).