next | previous | forward | backward | up | top | index | toc | home
Macaulay2Doc > The Macaulay2 language > operators > precedence of operators

precedence of operators

One aspect of parsing precedence is associativity. A left-associative operator is one, such as *, with the property that x * y * z is parsed as (x * y) * z. A right-associative operator is one, such as =, with the property that x = y = z is parsed as x = (y = z). These operators are left associative: # #? % & * ** + ++ , - . .. .? / // << @@ ^ ^** ^^ _ | ||, and these operators are right associative: != -> : := ; < <- <= <==> = =!= == === ===> ==> => > >= >> ? @ \ \\ |- and or SPACE .

Here are the operators arranged in order of increasing parsing precedence. For example, * has higher parsing precedence than +, and hence 2+3*5 is parsed as though it had been written as 2+(3*5). The symbol SPACE represents the operator that is used when two things are adjacent in program code.

 4                  ;                

 5                  ,                

 7        ->  :=  <-  =  =>  >>      

 9                  <<               

10                 ===>              

11                  |-               

12                 <==>              

13                 ==>               

14                  or               

15                 and               

16                 not               

17  !=  <  <=  =!=  ==  ===  >  >=  ?

18                  ||               

19                  :                

20                  |                

21                  ^^               

22                  &                

23                  ..               

24               +  ++  -            

25                  **               

27          %  *  /  //  \  \\       

28                  @                

29              (*)  SPACE           

30                  @@               

31              ^*  _*  ~            

32       #  #?  .  .?  ^  ^**  _     

33                  !                

See also