Node: The Program, Next: Label Declaration, Up: Source Structures

#### The Source Structure of Programs

A generic GNU Pascal program looks like the following:

         program name (Input, Output);

         import_part

         declaration_part

         begin
           statement_part
         end.

The `program` headline may be omitted in GPC, but a warning will be given except in `--borland-pascal` mode.

While the program parameters (usually `Input`, `Output`) are obligatory in ISO Pascal if you want to use `ReadLn` and `WriteLn`, they are optional in GNU Pascal. GPC will warn about such missing parameters in `--extended-pascal` mode. However if you give parameters to the program headline, they work like ISO requires.

The import_part consists either of an ISO-style `import` specification or a UCSD/Borland-style `uses` clause. While `import` is intended to be used with interfaces exported by ISO 10206 Extended Pascal modules, and `uses` is intended to be used with units, this is not enforced. (See also uses, import.)

The declaration_part consists of label, constant, type, variable or subroutine declarations in free order. However, every identifier must be declared before it is used. The only exception are type identifiers pointing to another type identifier which may be declared below.

The statement_part consists of a sequence of statements.

As an extension, GPC supports a “declaring statement” which can be used in the statement part to declare variables (see var).