Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/DelphiAST.SimpleParserEx.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
unit DelphiAST.SimpleParserEx;

{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}

interface

uses
Expand Down
79 changes: 79 additions & 0 deletions Test/DelphiASTTest.lpi
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="DelphiASTTest"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
</General>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
<Modes Count="0"/>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="2">
<Unit0>
<Filename Value="DelphiASTTest.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="uMainForm.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form2"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="DelphiASTTest"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="..\Source\SimpleParser;..\Source\FreePascalSupport;..\Source;..\Source\FreePascalSupport\Generics.Collection\src"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>
37 changes: 37 additions & 0 deletions Test/uMainForm.lfm
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
object Form2: TForm2
Left = 218
Height = 231
Top = 143
Width = 687
Caption = 'DelphiAST Test Application'
ClientHeight = 231
ClientWidth = 687
Color = clBtnFace
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
LCLVersion = '2.0.6.0'
object memLog: TMemo
Left = 0
Height = 193
Top = 0
Width = 687
Anchors = [akTop, akLeft, akRight, akBottom]
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Lucida Console'
ParentFont = False
ScrollBars = ssBoth
TabOrder = 0
end
object btnRun: TButton
Left = 604
Height = 25
Top = 198
Width = 75
Anchors = [akRight, akBottom]
Caption = 'Run'
OnClick = btnRunClick
TabOrder = 1
end
end
12 changes: 10 additions & 2 deletions Test/uMainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,
{$ELSE}
SysUtils, Variants, Classes, Controls, Forms, StdCtrls,
SysUtils, Variants, Classes, Controls, Forms, StdCtrls, Dialogs, FileUtil,
{$ENDIF}
SimpleParser.Lexer.Types;

Expand Down Expand Up @@ -41,7 +41,11 @@ implementation
uses
FileCtrl, IOUtils, DelphiAST, DelphiAST.Classes;

{$R *.dfm}
{$IFNDEF FPC}
{$R *.dfm}
{$ELSE}
{$R *.lfm}
{$ENDIF}

procedure TForm2.btnRunClick(Sender: TObject);
var
Expand All @@ -54,7 +58,11 @@ procedure TForm2.btnRunClick(Sender: TObject);
if not SelectDirectory('Select Folder', '', Path) then
Exit;

{$IFNDEF FPC}
for FileName in TDirectory.GetFiles(Path, '*.pas', TSearchOption.soAllDirectories) do
{$ELSE}
for FileName in FindAllFiles(Path, '*.pas', true) do
{$ENDIF}
begin
try
SyntaxTree := TPasSyntaxTreeBuilder.Run(FileName, False, TIncludeHandler.Create(Path));
Expand Down