views:

1841

answers:

8

I need a complete Object Pascal syntax (preferably Delphi 2009). Some of the syntax is given by the help files, but not all information is provided. So I started collecting loose bits of information. Recently I added these to a more or less complete syntax description (EBNF like).

Although it looks extensive, there are still bugs and I'm sure parts are missing (specially in the .NET syntax). So I'm asking the SO Delphi community. Do you have any information or can you correct the errors? In return I provide the complete syntax to the community. It probably saves you some time ;-). In the future, I like to do the same for other languages (Like C#/C++/Java).

The syntax description I already have is given: My Syntax sofar. Or if you like a Text version. (The XHTML is generated from the text version).

Please note that the syntax focusses on the syntactical part, because the lexical part is not really a problem.

Update

I have a new version of the Delphi Syntax. html version. It includes al versions including 2009. Prism extentions are still on the todo list. And I'm not sure if I'm going to keep them together.

For the real purists, it also contains the full assembler code (which does not support the full 100% of the intel set but only a few instructions are missed.).

+1  A: 

What exactly are the bugs and functionality you're missing?

From scanning over your document, it seems you mingle syntax and semantics. I do not understand why to distinguish between SimpleTypeFloat and SimpleTypeOrdinal on a syntactic level, or code operator precedence as syntactic feature in AddOp and MulOp. true, false, nil are identifiers just as any variable name you choose.

devio
A: 

You could always read the source to the Free Pascal Compiler. It supports Object Pascal.

Hugh Allen
Or just try to run your parser on the FPC testsuite. It has a lot of example programs of the more "ODD" Obj Pascal features
Marco van de Voort
A: 

God, last time I saw a copy of the PDF reference for the entire language was a long time ago. Normally there's a pretty good reference manual in %PROGRAM_FILES%\CodeGear\Rad Studio\5.0\Help (for D2007)
There should be a reference to the language syntax hiding somewhere on the Codegear web site.

Petesh
+10  A: 

Try this: DGrok - Delphi grammar

DiGi
This looks promissing. Thanx!
Gamecat
+1  A: 

There is no complete, published syntax for Delphi. Bear in mind that .net and win32 delphi have different syntaxes.

This project has hand-build Delphi parser in it. And lots of test cases of code that compiles but pushes the limits of the syntax.

Anthony
A: 

Try http://docs.codegear.com/

Mike Sutton
A: 

Delphi 7's grammar is in the back of the Object Pascal book.

You mean for a few thousand dollars they don't even send you that? Do they even send you a 6' x 6' poster?

Peter Turner
Nope, I they don't have it either. Thats why.
Gamecat
+1  A: 

This might be a good help. It is the parser used in TwoDesk's Castalia.

Jim McKeeth
The FPC using RAD, Lazarus has also highlighting parsers based on mw* (later synhighlighter)
Marco van de Voort