Main Page | Report this Page
Computers Forum Index  »  Computer Compilers  »  Delphi parser from TextTransformer grammar...
Page 1 of 1    

Delphi parser from TextTransformer grammar...

Author Message
Detlef Meyer-Eltz...
Posted: Sun Aug 23, 2009 5:13 pm
Guest
There is a TextTransformer grammar now for the creation of a Delphi
parser. I think, that this is worth mentioning here because there have
been a lot of attempts to create such a grammar for other parser
generators, but no grammar is published, that really works without
severe restrictions.

The reason is, that there are some special difficulties with the
Delphi grammar:

- there is no standard specification of this proprietary language. The
specification has to be concluded from the Delphi help files. So
indeed, the completeness of the grammar cannot be proved. The actual
project can parse the complete VCL which accompanies the CBuilder 6
and it was tested at more than 2000 files of my installed Delphi
components.

- though the grammar can be made nearly LL(1) conform, there are cases
where looking-ahead in the code cannot be avoided. TextTransformer can
do so, but the project was written so that look-ahead's are as rare as
possible.

- there are non-reserved keywords like "read" or "name", which also
can be used as identifiers. TextTransformer has the special option, to
look for the expected tokens only. So these keywords are recognized at
places only, where they are allowed to occur.


You can read more about the grammar and download it here:

http://www.texttransformer.org/Delphi_en.html

The conditional compiling is managed by a preprocessor:

http://www.texttransformer.org/Delphi_pp_en.html

The use of the grammar is demonstrated by a Delphi pretty-printer:

http://www.texttransformer.org/DelphiPrettyPrint_en.html

The pretty-printer can be called from Delphi too by means of the
TetraComponents. That can be tested directly with the example binary,
which is contained in the package:

http://www.texttransformer.org/Components.html

Last but not least TextTransformer 1.7.2 just has been released at:

http://www.texttransformer.com
 
Marco van de Voort...
Posted: Thu Aug 27, 2009 5:54 pm
Guest
On 2009-08-23, Detlef Meyer-Eltz <Meyer-Eltz at (no spam) t-online.de> wrote:
Quote:
The reason is, that there are some special difficulties with the
Delphi grammar:

- there is no standard specification of this proprietary language. The
specification has to be concluded from the Delphi help files. So
indeed, the completeness of the grammar cannot be proved. The actual
project can parse the complete VCL which accompanies the CBuilder 6
and it was tested at more than 2000 files of my installed Delphi
components.

You could try to run Free Pascal's testsuite. Many of the tests originate in
Delphi incompability bugreports.
 
Detlef Meyer-Eltz...
Posted: Tue Sep 01, 2009 7:59 pm
Guest
Quote:
You could try to run Free Pascal's testsuite.

That's a very good idea!

Such tests can be done very well inside of the TextTransformer IDE.
Files, which produce errors can be opened into the debugger by a
double click.

I had to remove the tests for Free Pascal specific extensions and the
tests for the Macintosh variant and I had to do some more adaptions
too. But this was worth the work. I could make a lot of small
improvements for special Delphi constructions.

More about the tests and a download of the modified test suite is
here:

http://www.texttransformer.org/Delphi_en.html

Thank you for this valuable feedback.
 
Marco van de Voort...
Posted: Mon Sep 07, 2009 7:13 am
Guest
On 2009-09-01, Detlef Meyer-Eltz <Meyer-Eltz at (no spam) t-online.de> wrote:
Quote:
That's a very good idea!

I'm glad it was of use to you.

Quote:
More about the tests and a download of the modified test suite is
here:

http://www.texttransformer.org/Delphi_en.html

If you know specific constructs for the supported versions (roughly up to
and including D7) that are not covered by the suite, please add a note to
the FPC bugtracker (http://bugs.freepascal.org), thanks.
 
 
Page 1 of 1    
All times are GMT
The time now is Sun Nov 29, 2009 8:52 am