[fpc-devel] Semicolon before else

Aleksa Todorovic alexione at gmail.com
Fri Jan 29 07:49:31 CET 2010


On Fri, Jan 29, 2010 at 00:00, Juha Manninen <juha.manninen at phnet.fi> wrote:
>
> How does your patch handle this? :
>
>  if a then
>    if b then
>     DoSomething;
>   else
>     DoOtherThing;
>

else is handled as part of "if b then" -> the closest preceeding if:

program test3;
var
  x: Integer;
begin
  x := 1;
  if x < 2 then
    if x > 0 then
      Writeln('x=1');
    else
      Writeln('x=0');
  Writeln('---');
end.

D:\alexa\dev\fpc\test\if>pp.exe
@d:\dev\fpc\fpc\bin\bin\i386-win32\fpc.cfg -vV test3.pas
Free Pascal Compiler version 2.5.1 [2010/01/28] for i386
Copyright (c) 1993-2009 by Florian Klaempfl
Target OS: Win32 for i386
Compiling test3.pas
Linking test3.exe
13 lines compiled, 1.4 sec , 26032 bytes code, 1560 bytes data

D:\alexa\dev\fpc\test\if>test3.exe
x=1
---



More information about the fpc-devel mailing list