Next: , Previous: , Up: Syntax   [Contents]

2.4 Builtin Operators

The following table lists all of Mercury’s builtin operators. Operators with a low “Priority” bind more tightly than those with a high “Priority”. For example, given that `+` has priority 500 and `*` has priority 400, the term `2 * X + Y` would parse as `(2 * X) + Y`.

The “Specifier” field indicates what structure terms constructed with an operator are allowed to take. “f” represents the operator and “x” and “y” represent arguments. “x” represents an argument whose priority must be strictly lower than that of the operator. “y” represents an argument whose priority is lower or equal to that of the operator. For example, “yfx” indicates a left-associative infix operator, while “xfy” indicates a right-associative infix operator.

```
Operator                        Specifier         Priority

.                               yfx               10
!                               fx                40
!.                              fx                40
!:                              fx                40
@                               xfx               90
^                               xfy               99
^                               fx                100
:                               yfx               120
`op`                      yfx               120       (1)
**                              xfy               200
-                               fx                200
\                               fx                200
*                               yfx               400
/                               yfx               400
//                              yfx               400
<<                              yfx               400
>>                              yfx               400
div                             yfx               400
mod                             xfx               400
rem                             xfx               400
+                               fx                500
+                               yfx               500
++                              xfy               500
-                               yfx               500
--                              yfx               500
/\                              yfx               500
\/                              yfx               500
..                              xfx               550
:=                              xfx               650
=^                              xfx               650
<                               xfx               700
=                               xfx               700
=..                             xfx               700
=:=                             xfx               700
=<                              xfx               700
==                              xfx               700
=\=                             xfx               700
>                               xfx               700
>=                              xfx               700
@<                              xfx               700
@=<                             xfx               700
@>                              xfx               700
@>=                             xfx               700
\=                              xfx               700
\==                             xfx               700
~=                              xfx               700
is                              xfx               701
and                             xfy               720
or                              xfy               740
func                            fx                800
impure                          fy                800
pred                            fx                800
semipure                        fy                800
\+                              fy                900
not                             fy                900
when                            xfx               900
~                               fy                900
<=                              xfy               920
<=>                             xfy               920
=>                              xfy               920
all                             fxy               950
arbitrary                       fxy               950
promise_equivalent_solutions    fxy               950
promise_equivalent_solution_sets fxy              950
promise_exclusive               fy                950
promise_exclusive_exhaustive    fy                950
promise_exhaustive              fy                950
promise_impure                  fx                950
promise_pure                    fx                950
promise_semipure                fx                950
require_complete_switch         fxy               950
require_det                     fx                950
require_semidet                 fx                950
require_multi                   fx                950
require_nondet                  fx                950
require_cc_multi                fx                950
require_cc_nondet               fx                950
require_erroneous               fx                950
require_failure                 fx                950
some                            fxy               950
,                               xfy               1000
&                               xfy               1025
->                              xfy               1050
;                               xfy               1100
then                            xfx               1150
if                              fx                1160
else                            xfy               1170
::                              xfx               1175
==>                             xfx               1175
where                           xfx               1175
--->                            xfy               1179
type                            fx                1180
solver                          fy                1181
end_module                      fx                1199
import_module                   fx                1199
include_module                  fx                1199
initialise                      fx                1199
initialize			fx		  1199
finalise			fx		  1199
finalize			fx		  1199
inst                            fx                1199
instance                        fx                1199
mode                            fx                1199
module                          fx                1199
pragma                          fx                1199
promise                         fx                1199
rule                            fx                1199
typeclass                       fx                1199
use_module                      fx                1199
-->                             xfx               1200
:-                              fx                1200
:-                              xfx               1200
?-                              fx                1200

```

(1)

Operator term (see Terms).

Next: , Previous: , Up: Syntax   [Contents]