Contents | Prev | Next | Index


Variable Declarations

Variable declarations serve to introduce and associate them with a unique identifier and a data type. The following grammar shows Java-specific extensions is red color:

var_decl       ::= var_ident_list : type
var_ident_list ::= var_ident_list , var_ident
               ::= var_ident
var_ident      ::= <identifier>
               ::= <identifier> [ <string> ]
               ::= <identifier> java_name

In this compiler, if the generated Java identifier is to be different from the variable identifier, that Java identifier may be specified after the Pascal identifier, either as a string or as a JAVA NAME directive.

Class and pointer variables have both a static type and a dynamic type (the type they assume at run time). For variable parameters of class type, the dynamic type may be an subclass of their static type.

Examples of variable declarations (see also section about type declarations):

VAR
 
i,j,k : INTEGER;
 
x,y : REAL;
  p, q : BOOLEAN;
  s : SET OF 0..31;
  F : Func;
  a : ARRAY [1..100] OF REAL;
  w : ARRAY [1..16] OF RECORD
        name : ARRAY [0..31] OF CHAR;
        count : INTEGER;
      END;
  t,c : Tree;


Contents | Prev | Next | Index

Canterbury Pascal for JVM  (Last documentation update Sep 02, 2004)
Copyright © 1999-2004 J.Neuhoff - mhccorp.com  . All rights reserved.
Please send any comments or corrections to neuhoff@mhccorp.com