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


2.6 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
event                           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
for                             xfx               500
+                               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
atomic                          fxy               950
disable_warning                 fxy               950
disable_warnings                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_switch_arms_det         fxy               950
require_switch_arms_semidet     fxy               950
require_switch_arms_multi       fxy               950
require_switch_arms_nondet      fxy               950
require_switch_arms_cc_multi    fxy               950
require_switch_arms_cc_nondet   fxy               950
require_switch_arms_erroneous   fxy               950
require_switch_arms_failure     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
trace                           fxy               950
try                             fxy               950
some                            fxy               950
,                               xfy               1000
&                               xfy               1025
->                              xfy               1050
;                               xfy               1100
or_else                         xfy               1100
then                            xfx               1150
if                              fx                1160
else                            xfy               1170
::                              xfx               1175
==>                             xfx               1175
where                           xfx               1175
--->                            xfy               1179
catch                           xfy               1180
type                            fx                1180
solver                          fy                1181
catch_any                       xfy               1190
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


Footnotes

(1)

Operator term (see Terms).


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