Description
Compound statements group a statement-sequence (i.e. one or more statements) into a single statement, and are executed as follows:
Example
For example look at the program fragment below:
write('Do you want to continue');
readln(answer);
if (answer = 'n') or (answer = 'N') then
begin
writeln('Program terminated by user');
halt
end
here we want to write a message to the screen and stop if the user answers n or N, but this requires two statements and the then-part of an if statement allows only a single statement. The solution as you can see is to put the two statements into a compound statement.
Syntax
(NOTE: for clarity some parts of the syntax are omitted, see Irie Pascal Grammar for the full syntax):
compound-statement = 'begin' statement-sequence 'end'
statement-sequence = statement { ';' statement }