Working with the Castalia Delphi Parser#

Last week I asked for a list of Delphi parsers/lexers, to analyze Pascal/Delphi files. One of the solutions named, and by far the best one, was the Castalia Delphi Parser. After playing with it a while I started to see what it really can do. While it is not the easiest to use, it goes a long way. However, I ran into some wall. Files like Windows.pas and System.pas from the original Delphi distribution (checked against Delphi 2007) cannot be parsed with it.

For Windows.Pas, it stops on the declaration of the type DWORD.

type
{ Translated from WINDEF.H }

  WCHAR = WideChar;
  {$EXTERNALSYM WCHAR}
  PWChar = PWideChar;

  LPSTR = PAnsiChar;
  {$EXTERNALSYM LPSTR}
  PLPSTR = ^LPSTR;
  {$EXTERNALSYM PLPSTR}
  LPCSTR = PAnsiChar;
  {$EXTERNALSYM LPCSTR}
  LPCTSTR = PAnsiChar;
  {$EXTERNALSYM LPCTSTR}
  LPTSTR = PAnsiChar;
  {$EXTERNALSYM LPTSTR}
  LPWSTR = PWideChar;
  {$EXTERNALSYM LPWSTR}
  PLPWSTR = ^LPWSTR;
  {$EXTERNALSYM PLPWSTR}
  LPCWSTR = PWideChar;
  {$EXTERNALSYM LPCWSTR}

  DWORD = Types.DWORD;
  {$EXTERNALSYM DWORD}

In System.pas it stops, because it cannot handle {$IFDEF} blocks very well. When coming to the second time when unwind is declared (this time for Linux) it stops, because it needs a new const before it.

const
{$IFDEF MSWINDOWS}
  unwind = 'unwind.dll';

type
  UNWINDelphi-PRAXiSROC  = Pointer;
function UnwindRegisterIPLookup(fn: UNWINDelphi-PRAXiSROC; StartAddr, EndAddr: LongInt; Context: Pointer; GOT: LongInt): LongBool; cdecl;
  external unwind name '__BorUnwind_RegisterIPLookup';

function UnwindDelphiLookup(Addr: LongInt; Context: Pointer): UNWINDelphi-PRAXiSROC; cdecl;
  external unwind name '__BorUnwind_DelphiLookup';

function UnwindRaiseException(Exc: Pointer): LongBool; cdecl;
  external unwind name '__BorUnwind_RaiseException';

function UnwindClosestHandler(Context: Pointer): LongWord; cdecl;
  external unwind name '__BorUnwind_ClosestDelphiHandler';
{$ENDIF}
{$IFDEF LINUX}
  unwind = 'libborunwind.so.6';

Do you have a solution for those problems, or do you now another parser/lexer which will help me along.

Thanks and a Happy New Year,
Daniel

Friday, December 28, 2007 4:34:08 PM (W. Europe Standard Time, UTC+01:00) #    Comments [0]  | 

 

Google AdSense


Searching your Delphi files...#

Yesterday, I asked you guys for a list of Pascal/Delphi parsers. Today I ask you how I should really use it.

What I am going to do...

I am currently writing a indexing filter, that will index your Delphi/Pascal files with the Windows Search Desktop, which comes with MS Windows Vista, and is available for download for Windows XP. The same library can be used with the old indexing service of Windows 9X/ME/200X.

Why I am doing this...

Because I like to find my libraries when I need them. Over the years I have created literally thousands of units and sometimes it just takes a while to find a simple helper function I have written back then... The Windows Desktop Search is great, when you feed it with optimized data. This is what I am going to do for your Pascal/Delphi files.

Does this really work...

You remember ever searching your files and not finding them, though you just know they are there. Well, this is because the Indexing service needs to be told what to index, where to index and how to index. Once you do this, yes, it works, always! I am going to help you with the what and the how for the Pascal files. You just have to determine the where.

How a plan to implement the idea (for now)...

I simply thought I'll parse the interface part of all units (all parts for .dpr and .inc files) and index the name of all classes, types, methods, functions, procedures, properties, constants, variables as keywords. Further I would index the whole declaration of those as well as comments for full-text search.

This way you can search the declarations and the comments of your files on the fly and literally instantly.

How would you implement the idea...

What else should I index - or how should I index those data? Any comments, ideas, etc. are very welcome. I'll plan to release the first beta in January. So let me know what you want.

Thanks for reading, now send me a message ;-)

 

Sunday, December 23, 2007 4:47:09 PM (W. Europe Standard Time, UTC+01:00) #    Comments [8]  | 

 

I am looking for a basic (or good) Delphi lexer#

Well, I know about DGrok, which seems to be a great tool. However, it is written all in C# and therefore all in .NET only. For a upcoming project, which I want to make open source once finished, I need a lexer, which is written in native Pascal/Delphi. It does not need to be perfect, however, it should return all data of the interface part in units, and it should analyze Delphi-PRAXiSR-Files as well.

The lexer (maybe a simple parser suffices) must be open source and come with just about any license out there, though I prefer MPL over (L)GPL any day.

Anyone with a good hint out there? Thanks!

P.S.: Merry Christmas and a happy new year.

Saturday, December 22, 2007 4:10:15 PM (W. Europe Standard Time, UTC+01:00) #    Comments [5]  | 

 

More on the Zoom and SuperZoom#

My last post was on the Zoom-Feature of the Delphi 2007 IDE. During the last hours I played around a little with it. One of the comments mentioned the option SuperZoom, which is even nicer. However, in a multi-monitor setup, SuperZoom always places the editor on the main monitor, which is not always the one I want to work on. So, it is nice to have, but I'll stay with the Zoom option for now, this one works as expected.

Thursday, December 13, 2007 12:25:17 PM (W. Europe Standard Time, UTC+01:00) #    Comments [2]  | 

 

Full Screen Editor in Delphi 2007 IDE#

Alfonso, a member of the Delphi-PRAXiS has seen an undocumented feature in an presentation and shared it with the community. Since many of you don't read the German forum or may just miss it in the wealth of information flowing through the Delphi-PRAXiS, here is a very nice registry hack.

Navigate to your registry key [HKEY_CURRENT_USER\Software\Borland\BDS\5.0\Editor] and create a string entry with the name Zoom and the Value Zoom.

Now, when double clicking on the tab of the editor it will go to the full width of your screen. Nice feature!

Sorry that I write only rarely lately, but this is due to me doing lots of web development during the last weeks and will change after the holiday season, again.   

Wednesday, December 12, 2007 12:51:41 PM (W. Europe Standard Time, UTC+01:00) #    Comments [5]  | 

 

All content © 2010, Daniel Wischnewski
On this page
Archives
Promoted Links
Blogroll OPML
My current Flickr Images
www.flickr.com
Dies ist ein Flickr Modul mit �ffentlichen Fotos und Videos von dwischnewski. Ihr eigenes Modul k�nnen Sie hier erstellen.
Recommendations
Sitemap
Special Pages
Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Theme design by Jelle Druyts