[fpc-pascal] Labels
Adriaan van Os
adriaan at adriaan.biz
Sun Dec 17 17:47:33 CET 2023
According to Section 13.0 of the FreePascal Language Reference (version 3.2.0)
"A label can be an identifier or an integer digit."
What may be meant is that a label can be an identifier or an integer digit-sequence (and that's
what the compiler accepts)
label := digit-sequence | identifier .
ISO-7185 and ISO-10206 Pascal both define
label = digit-sequence .
UCSD-Pascal defines
label = unsigned-integer ":" .
Turbo Pascal (5.5) defines
label = digit-sequence .
in the range 0..9999
MetroWerks Pascal (unfortunately) defined a label as
label = identifier .
The reason for restricting labels to digit-sequences (excluding identifiers) is a parsing problem:
a :=3;
can also be read as
a : ......
which is the optional <[ label ":" ]> in the rule for <statement>.
statement = [ label ":" ] [ simple-statement | structured-statement | asm-statement ] .
This can be solved, of course, but misses the elegance of the ISO-7185/ISO-10206/UCSD/Turbo Pascal
label definition.
Regards,
Adriaan van Os
More information about the fpc-pascal
mailing list