Previous Contents Next

4   Expressions

expr   ::=   boolean-literal
  | integer-literal
  | ident
  | ( expr )
  | uop expr
  | expr binary-operator expr
unary-operator   ::=   - | !
binary-operator   ::=   + | - | * | / | %
  | && | ||
  | == | != | < | > | <= | >=

The table below shows the relative precedence and associativity of operators. The operators are ordered top-down from the highest to the lowest precedence.



Operators Associativity
!   right to left
* / %   left to right
+ -   left to right
< <= > >= left to right
== !=   left to right
&&   left to right
||   left to right
Note that the unary operator - has higher precedence than binary operators.


Previous Contents Next