What are operators?

Below is a table of all the operators supported by Irie Pascal in order of decreasing precedence. All operators on the same line have the same precedence. Operations with operators of the same precedence are performed left to right. Parantheses can be used to control the order in which operations are performed by grouping operations that should be performed first.

   -----------------------------
   not
   -----------------------------
   *  /  div  mod  and  and_then
   -----------------------------
   +  -  or  or_else  xor
   -----------------------------
   shl  shr
   -----------------------------
   =  <> <  <=  >  >=  in
   -----------------------------

So for example with the expression below

   2 + 3 - 1

the addition would be performed before the subtraction. This is because "+" and "-" have the same precedence and so the operations are performed from left to right.

However since "*" has a higher precedence then with the expression below

   2 + 3 * 1

the multiplication is permormed before the addition. Using the same example above you can force the addition to be performed first by using parentheses like so:

   (2 + 3) * 1

For more complicated expressions you can use nested parentheses, in which case the operatings enclosed in the inner-most parentheses are performed first. So for example given

   2 + (4 - 1) * (4 div (2 + 2))

the first operation performed is 2 + 2 which yields 4, resulting in the expression below

   2 + (4 - 1) * (4 div 4)

Now we have two nested parentheses at the same level so which operation is performed first? Well operations at the same level of precedence are performed left to right so the (4 - 1) is performed next resulting in

   2 + 3 * (4 div 4)

Next the 4 div 4 is performed resulting in

   2 + 3 * 1

Next the 3 * 1 is performed resulting in

   2 + 3

which results in the integer value 5

Operator Categories

Operators can be grouped into the following categories: