I am looking in detail at the syntax diagrams in the Freepascal Language
Reference (version 3.2.0)
Section 13.2.2 discusses the case-statement. Translated to EBNF (WSN) the
syntax is
case-statement = "CASE" expression "OF" case { ";" case } [ else-part ] [ ";" ]
.
case = constant [ ".." constant ] { "," constant [ ".." constant ] } ":"
statement .
else-part = [ "ELSE" | "OTHERWISE" ] statementlist .
If this is correct (and the compiler really allows it) then a semicolon between <case> and
<else-part> is not required. Consequently, there is an ambiguity between an if-then-else statement
(as last statement of the <case>) and an if-then statement (as last statement of the <case>) and an
<else-part>. This is extremely dangerous and I feel that at least the Language Reference should
warn against it.
Even with an obliged semicolon, I always use "OTHERWISE instead of ELSE, but that's my personal
preference.
By the way, the Language Reference doesn't specify what a <statementlist> is.
Regards,
Adriaan van Os
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal