Contents    Page-10    Prev    Next    Page+10    Index   

Operator Precedence Expressions could be written in an unambiguous, fully parenthesized form. However, this is less convenient for the programmer.

Precedence specifies which operations in a flat expression are to be performed first. B * C is performed first in A + B * C; * takes precedence over +, * >         · +.

Associativity specifies which operations are to be performed first when adjacent operators have the same precedence. A + B is performed first in A + B + C since + is left-associative. B ** C is performed first in A ** B ** C since ** is right-associative.

Typical precedence values [ not Pascal]:


10   .                 (highest precedence)
 9   ^
 8   - (unary)
 7   *  /
 6   +  -
 5   =  <>  >=  >  <=  <
 4   not
 3   and
 2   or
 1   :=                (lowest precedence)