HANDBOOK / CASE STUDY / The Source Language /

# Expressions

Expressions are constructs denoting rules of computation for obtaining values of variables and generating new values by the application of operators. Expressions consist of operators and operands, i.e. variables and constants.

The rules of composition specify operator precedences according to four classes of operators. The operator NOT has the highest precedence, followed by the multiplying operator '*', the adding operator '+', and finally, with the lowest precedence, the relational operator. Sequences of operators of the same precedence are executed from left to right.

    Expr ::= Expr ( '+' | '*' | '<' ) Expr | 'NOT' Expr
         | '(' Expr ')' | Var | IntConst | RealConst
         | 'TRUE' | 'FALSE'

Examples:

    i       15        TRUE       2*(i+r)
    NOT b   NOT (i<1)

The operators are summarized in the following table:

Note that, for Boolean values, FALSE < TRUE.