next up previous contents index
Next: External Procedures Up: Program Structure Previous: Program Structure

The ZPL Module

 

The ZPL compiler does not currently support separate compilation, so all ZPL code must reside in a single file (files may be included using the C pre-processor--see Section 9.1), but the compiler sees a single source file). The ZPL source file has the following syntax.

 
		 program 		 Identifier 		;

Declarations

Procedures

The program's name, Identifier, must be a legal ZPL identifier (see Section 2.4.1). Declarations represents the set of globally defined config variables, constants, types and variables, as well as the program's directions and regions, which can only be defined at the global level. Declarations consist of any number of the following items in any order, where curly braces indicate an item that may be repeated zero or more times.

 1231Tconfig var12¯{EIdentifierT:EListTconfig var 				 Identifier		 : 		 Type = 
		       Expression;

{Identifier : Type = Expression;}

constant Identifier : SequentialType = Expression;

{Identifier : Type = Expression;}

type Identifier = Type;

{Identifier = Type;}

direction Identifier = [Vector];

{Identifier = [Vector];}

region Identifier = [DimensionList];

{Identifier = [DimensionList];}

var IdentifierList: Type;

{IdentifierList: Type;}

Procedures represent procedure declarations and procedure prototypes. The general form of a procedure body is shown below. A procedure prototype consists of just the ProcedureHeader.

 
		 procedure 				 Identifier ( 
		    {
		      {var}
		      IdentifierList: 
		      Type})
	            {: Type };

LocalVars

Statement

The local variables (LocalVars) of a procedure have the same form as the global variable declarations shown above, and the body is simply a ZPL statement (typically a compound statement using the begin and end construct). Note that only variables can be defined local to a procedure. Constants, tyes, directions, or regions definitions are not allowed to be defined local to a procedure.

One procedure must have the same name as the program name. This procedure is the program's entry point.



Kay Nettle
Fri Feb 21 21:14:29 CST 1997