Contents | Prev | Next

8.1 What are expressions?

Description

Expressions describe a sequence of operations to be performed on one or more operands that result in a single value of a particular type. The operations to be performed are specified by operators.

Example

Here are some examples of expressions:

   3+5      which results in the integer value 8
   3+5.0    which results in the real value 8.0
   1+2*3    which results in the integer value 7
   (1+2)*3  which results in the integer value 9

Syntax

(NOTE: for clarity some parts of the syntax are omitted, see Irie Pascal Grammar for the full syntax):

   expression = shift-expression [ relational-operator shift-expression ]

   adding-operator = '+' | '-' | 'or' | 'or_else' | 'xor'

   factor = [ sign ] unsigned-constant |
                [ sign ] variable-access |
                [ sign ] '(' expression ')' |
                [ sign ] function-designator |
                [ sign ] function-method-designator |
                [ sign ] 'not' factor |
                set-constructor

   multiplying-operator = '*' | '/' | 'div' | 'mod' | 'and' | 'and_then'

   relational-operator = '=' | '<>' | '<' | '<=' | '>' | '>=' | 'in'

   shift-expression = simple-expression [ shift-operator simple-expression ]

   shift-operator = 'shl' | 'shr'

   sign = '-' | '+'

   simple-expression = term { adding-operator term }

   term = factor { multiplying-operator factor }

Contents | Prev | Next