Browse Source

* Fix for bug #37760

git-svn-id: trunk@47019 -
michael 4 years ago
parent
commit
abe463d576
1 changed files with 14 additions and 1 deletions
  1. 14 1
      packages/fcl-passrc/src/pparser.pp

+ 14 - 1
packages/fcl-passrc/src/pparser.pp

@@ -5986,7 +5986,20 @@ begin
               El:=nil;
             end;
             if (CurToken=tkelse) and (TPasImplIfElse(CurBlock).ElseBranch=nil) then
-              break; // add next statement as ElseBranch
+              begin
+                // Check if next token is an else too
+                NextToken;
+                if CurToken = tkElse then
+                  begin
+                    // empty ELSE statement without semicolon e.g. if condition then [...] else else
+                    El:=TPasImplCommand(CreateElement(TPasImplCommand,'', CurBlock,CurTokenPos));
+                    CurBlock.AddElement(El); // this sets TPasImplIfElse(CurBlock).IfBranch:=El
+                    El:=nil;
+                    CloseBlock;
+                  end;
+                UngetToken;
+                break; // add next statement as ElseBranch
+              end;
             end
           else if (CurBlock is TPasImplTryExcept) and (CurToken=tkelse) then
             begin