I am dabbling with the Object Pascal Engine (by Rob van den Brink) and it seems (except for a few minor and easily correctable errors) it works for Delphi unit files.
However, it has problems parsing Project (.dpr) and Package (.dpk) files; and the issue basically boils down to the differences between the stuff that 'uses' can have in units and projects (as well as what 'contains' clause can have in packages).
Let me give simple examples:
In a unit (.pas) file, the 'uses' clause can be something like this
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
ExtCtrls,
ComCtrls;
whereas, in a Project (.dpr) file
uses
Forms,
UnitDemoMain in 'UnitDemoMain.pas' {Form1},
SomeUnit in '..\SomeUnit.pas',
SomeOtherUnit;
Yet, the same functionality (in the name of 'contains') occurs as:
contains
OneUnit in 'OneUnit.pas',
AnotherUnit in '..\AnotherUnit.pas';
The problem with the grammar file I have (from the above link) is that it only handles the most simple case (i.e. the way 'uses' occurs in unit files), and throws error for others.
I am guessing it boils down how 'IdList' is defined in the grammar file, which is this:
<IdList> ::= <IdList> ',' <RefId>
| <RefId>
My question, then, is: How do I alter this definition, so that it can handle other alternatives (as seen in Project and Pacckage files), i.e.:
UnitDemoMain in 'UnitDemoMain.pas' {Form1},
OneUnit in 'OneUnit.pas';