HANDBOOK / CASE STUDY / The Source Language /

# Declarations and Denotations of Variables

Variable declarations consist of an identifier denoting the new variable, followed by its type.

    VarDecl ::= Id ':' Type

Examples:

    i: INTEGER
    r: REAL
    b: BOOLEAN
    a: ARRAY [4..7] OF ARRAY [2..2] OF INTEGER

Denotations of variables either designate an entire variable or a component of an array variable. Variables occurring in examples in subsequent chapters are assumed to be declared as indicated above.

    Var ::= Id | Var '[' Expr ']'

Examples:

    i   a[4][2]

An entire variable is denoted by its identifier. A component of an array variable is denoted by the variable followed by an index expression. The value of the index expression must lie in the range of the indices of the corresponding array type.