The simplest valid ALGOL program is a BEGIN/END pair. The BEGIN/END pair can enclose a list of declarations, a list of modules, or a list of statements. If the BEGIN/END pair is preceded by a procedure heading, the entire program is a procedure, which can be typed or untyped and can have one or more parameters.
Program units can be blocks, compound statements, level 2 procedures, or separate procedures that have a lexical (lex) level of three or greater and that can have global declarations.
A block is a statement that groups one or more declarations and statements into a logical unit by using a BEGIN/END pair. A compound statement is a statement that groups one or more statements into a logical unit by using a BEGIN/END pair. A compound statement is a block without any declarations.
The definitions of a compound statement and a block are recursive: both compound statements and blocks are made, in part, of statements. A statement can itself be a compound statement or a block, as you can see in the following sample:
Compound Statements
BEGIN BEGIN
<statement>; <statement>;
<statement>; <statement>;
. BEGIN
. <declaration>;
. BEGIN
<statement>; <statement>;
END <statement>;
END;
END;
<statement>;
ENDBlocks
BEGIN BEGIN
<declaration>; <declaration>;
<declaration>; <declaration>;
. <statement>;
. BEGIN
. <declaration>;
<declaration>; <statement>;
<statement>; END;
<statement>; BEGIN
. <statement>;
. <statement>;
. <statement>;
<statement>; END;
END ENDA program unit that is a separate procedure is typically bound to a host program to produce a more complete program.
The <global part> construct allows global identifiers to be referenced within a separate procedure. Any program unit that has a global part is valid only for binding to a host.
A program unit can be preceded, but not followed, by a remark.
A compound statement is executed in-line and does not require a procedure entrance and exit. A block, however, is executed like a procedure and requires a procedure entrance and exit. Entering a block requires extra processor resources; entering a compound statement does not.
Examples
Compound Statement
BEGIN
DISPLAY("HI THERE");
DISPLAY("THAT̍S ALL FOLKS");
END.Block
BEGIN REAL X; X := 100; END.
Level 2 Procedure
PROCEDURE S; BEGIN REAL X; X := SQRT(4956); END.
Separate Procedure with Global Part
[REAL S; ARRAY B[0:255]; FILE LINE;] REAL PROCEDURE Q; BEGIN Q := S*B[4]; WRITE(LINE,/,"DONE"); END.
According to the syntax, the last statement of a block or compound statement is not followed by a semicolon (;). However, in the above examples (and throughout this manual), the last statement is always followed by a semicolon. This is valid because the statement before the END is the null statement.

