[fpc-pascal] Very odd case parsing problem

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sun Dec 29 08:33:00 CET 2013


Saunders, Rich wrote:
> On 2013-12-28 15:47, Mark Morgan Lloyd wrote:
>> 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
> 
> The problem is the compiler associates the else with the if..then and 
> not with the case statement. All your fixes break the possible 
> connection between the else and the if..then and that's why they work.
> 
> Your first fix (to just add a semicolon) would be my preferred one. I 
> have lots of code that is written that way. I'm not sure why you think 
> this is "strictly incorrect".

Drat- a dangling else in a case! I should have spotted that, but instead 
spent an hour or so picking at it.

-- 
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