[fpc-pascal] Very odd case parsing problem
Mark Morgan Lloyd
markMLl.fpc-pascal at telemetry.co.uk
Sat Dec 28 21:47:23 CET 2013
I've been wrestling with something for a chunk of the early evening,
which is reproducible in situ but not in a cut-down test program.
Using 2.6.2 on x86 Linux in objfpc mode, a case statement that looks
like this fails to parse:
try
case parseCommand(selector) of
help: begin
end;
help_: begin
end;
quit_: if High(lexemeListArray) = 1 then begin
end
else
end // line 323
finally
end;
As it stands, compilation fails with
centralcontrol/distributionanddisplay.pas(323,5) Error: Constant and
CASE types do not match
centralcontrol/distributionanddisplay.pas(323,5) Error: Constant
Expression expected
centralcontrol/distributionanddisplay.pas(323,5) Error: duplicate case label
centralcontrol/distributionanddisplay.pas(323,5) Fatal: Syntax error,
":" expected but "END" found
I can fix that either by putting a semicolon before the else- which I
believe is strictly incorrect- or by putting begin/end around that
conditional, or by inserting a dummy statement before the else like
quit_: if High(lexemeListArray) = 1 then begin
end;
nop: begin end
else
I suspect I might have seen this happen before, but it's not an easy one
to grep for. Does this make sense to anybody, is it a known (and
preferably fixed) issue, or should I be putting time into trying to
match the behaviour in a cut-down test program?
--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
More information about the fpc-pascal
mailing list