Book a Demo

Author Topic: Bugs in parsing Delphi code  (Read 3428 times)

jnavr

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Bugs in parsing Delphi code
« on: February 14, 2006, 12:50:38 am »
I have found another parser bugs in EA when I tried to import a large Delphi project into EA (the latest build 786). I am pleased that this build addresses the parse error bug caused by a property declaration using qualified structure members names.

Sometimes there is a workaround - to break the declaration into two or three simpler declarations (e.g. declarations of arrays of initialized structures). The {$} directives errors are especially very annoying.

1) The keyword "stdcall" causes a parse error in type declaration, while the same clause is accepted in a function declaration:

//parse error:
type
 TCrHndlFunc = function (DrvName, DevName, Output: PChar;
   InitData: PDevMode): HDC stdcall;

//OK:
function LongMulDiv(Mult1, Mult2, Div1: Longint): Longint; stdcall;
 external 'kernel32.dll' name 'MulDiv';

//OK, as well:
function AbortProc(Prn: HDC; Err: Integer): Boolean; stdcall;
begin
 ...
end;


2) Type or const declarations that include multiple initialization values cause a parse error:

//parse error:
type
 TCodePage = ('ISO-8859-1', 'ISO-8859-2', 'windows-1252', 'windows-1250');

const
 Functions: array [1..FuncCount] of record ID,Params: string end = (
      (ID: '555,0'; Params: '0=0,0;1=1,0;2=0,1;3=1,1'));


3) Variant parts in record declaration (using case ... of ...) also cause an error:

//parse error:
type
 PSockAddrIn = ^TSockAddrIn;
 sockaddr_in = record
   sin_family: u_short;
   case Integer of
     0: (sin_family: u_short;
         sin_port: u_short;
         sin_addr: TInAddr;
         sin_zero: array[0..7] of Char);
     1: (sa_family: u_short;
         sa_data: array[0..13] of Char)
 end;
 TSockAddrIn = sockaddr_in;


4) Some {$...} directives make parse errors:

{$IFDEF MGR}
{$DEFINE NOMACRO}
//parse error:
{$ENDIF}

//parse error:
{$MINENUMSIZE 4}

//parse error, very strange:
{ord()}

//parse error:
const ver = {$I ver.pas};

jnavr

thomaskilian

  • Guest
Re: Bugs in parsing Delphi code
« Reply #1 on: February 14, 2006, 03:19:34 am »
You should report this via Sparx bug report page.