Contents | Prev | Next

3.1 What are labels?

Labels are markers, which you can place in front of statements so that the statements can be referenced by goto statements. Labels can be digit sequences or identifiers. In Standard Pascal labels must be digit sequences. Leading zeroes are not significant in labels, so "009" and "9" are the same label.

Example

//*************************************************************
//This program counts counts from 1 to 10 using goto
//*************************************************************
program count(output);
label write_count;
const
   minimum = 1;
   maximum = 10;
var
   count : integer;
begin
   count := minimum;
   write_count: writeln(count);
   count := count + 1;
   if count <= maximum then goto write_count
end.

Labels must be declared (in a label declaration group) before they can be used.

Syntax

(NOTE: for clarity some parts of the syntax are omitted, see Irie Pascal Grammar for the full syntax):

   label-declaration-group = 'label' label { ',' label } ';'

   label = digit-sequence | identifier

   digit-sequence = digit { digit }

   digit = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

Contents | Prev | Next