From 08c031478c15abde97d9f119777afcd9bfd1d8c4 Mon Sep 17 00:00:00 2001 From: JulStrat Date: Sat, 24 Jul 2021 15:42:09 +0300 Subject: [PATCH] DelphiASTTest - Lazarus project file, form file, fixes for FPC 3.0.4 / Lazarus 2.0.6 --- Source/DelphiAST.SimpleParserEx.pas | 2 + Test/DelphiASTTest.lpi | 79 +++++++++++++++++++++++++++++ Test/uMainForm.lfm | 37 ++++++++++++++ Test/uMainForm.pas | 12 ++++- 4 files changed, 128 insertions(+), 2 deletions(-) create mode 100644 Test/DelphiASTTest.lpi create mode 100644 Test/uMainForm.lfm diff --git a/Source/DelphiAST.SimpleParserEx.pas b/Source/DelphiAST.SimpleParserEx.pas index 6afd7105..b2d2d6bb 100644 --- a/Source/DelphiAST.SimpleParserEx.pas +++ b/Source/DelphiAST.SimpleParserEx.pas @@ -1,5 +1,7 @@ unit DelphiAST.SimpleParserEx; +{$IFDEF FPC}{$MODE DELPHI}{$ENDIF} + interface uses diff --git a/Test/DelphiASTTest.lpi b/Test/DelphiASTTest.lpi new file mode 100644 index 00000000..9f11bef3 --- /dev/null +++ b/Test/DelphiASTTest.lpi @@ -0,0 +1,79 @@ + + + + + + + + + + <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> diff --git a/Test/uMainForm.lfm b/Test/uMainForm.lfm new file mode 100644 index 00000000..1d3ccd67 --- /dev/null +++ b/Test/uMainForm.lfm @@ -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 diff --git a/Test/uMainForm.pas b/Test/uMainForm.pas index 0c9b9277..f9070334 100644 --- a/Test/uMainForm.pas +++ b/Test/uMainForm.pas @@ -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; @@ -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 @@ -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));