mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 01:39:20 +02:00
compilers: started dcc parser
This commit is contained in:
parent
0c7e76c0a0
commit
f6f00f6001
38
components/compilers/delphi/lazdelphi.lpk
Normal file
38
components/compilers/delphi/lazdelphi.lpk
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CONFIG>
|
||||||
|
<Package Version="5">
|
||||||
|
<Name Value="LazDelphi"/>
|
||||||
|
<Type Value="RunAndDesignTime"/>
|
||||||
|
<CompilerOptions>
|
||||||
|
<Version Value="11"/>
|
||||||
|
<SearchPaths>
|
||||||
|
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
|
||||||
|
</SearchPaths>
|
||||||
|
</CompilerOptions>
|
||||||
|
<Files>
|
||||||
|
<Item>
|
||||||
|
<Filename Value="lazdelphireg.pas"/>
|
||||||
|
<HasRegisterProc Value="True"/>
|
||||||
|
<UnitName Value="lazdelphireg"/>
|
||||||
|
</Item>
|
||||||
|
</Files>
|
||||||
|
<RequiredPkgs>
|
||||||
|
<Item>
|
||||||
|
<PackageName Value="IDEIntf"/>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<PackageName Value="BuildIntf"/>
|
||||||
|
</Item>
|
||||||
|
<Item>
|
||||||
|
<PackageName Value="FCL"/>
|
||||||
|
</Item>
|
||||||
|
</RequiredPkgs>
|
||||||
|
<UsageOptions>
|
||||||
|
<UnitPath Value="$(PkgOutDir)"/>
|
||||||
|
</UsageOptions>
|
||||||
|
<PublishOptions>
|
||||||
|
<Version Value="2"/>
|
||||||
|
<UseFileFilters Value="True"/>
|
||||||
|
</PublishOptions>
|
||||||
|
</Package>
|
||||||
|
</CONFIG>
|
22
components/compilers/delphi/lazdelphi.pas
Normal file
22
components/compilers/delphi/lazdelphi.pas
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{ This file was automatically created by Lazarus. Do not edit!
|
||||||
|
This source is only used to compile and install the package.
|
||||||
|
}
|
||||||
|
|
||||||
|
unit LazDelphi;
|
||||||
|
|
||||||
|
{$warn 5023 off : no warning about unused units}
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
LazDelphiReg, LazarusPackageIntf;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
begin
|
||||||
|
RegisterUnit('LazDelphiReg', @LazDelphiReg.Register);
|
||||||
|
end;
|
||||||
|
|
||||||
|
initialization
|
||||||
|
RegisterPackage('LazDelphi', @Register);
|
||||||
|
end.
|
159
components/compilers/delphi/lazdelphireg.pas
Normal file
159
components/compilers/delphi/lazdelphireg.pas
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
unit LazDelphiReg;
|
||||||
|
|
||||||
|
{$mode objfpc}{$H+}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
Classes, SysUtils, IDEExternToolIntf, RegExpr;
|
||||||
|
|
||||||
|
const
|
||||||
|
SubToolDelphi = 'Delphi';
|
||||||
|
|
||||||
|
type
|
||||||
|
|
||||||
|
{ TDelphiCompilerParser }
|
||||||
|
|
||||||
|
TDelphiCompilerParser = class(TExtToolParser)
|
||||||
|
private
|
||||||
|
protected
|
||||||
|
FRegExprFilenameLineIDMsg: TRegExpr;
|
||||||
|
FRegExprFilenameLineUrgencyIDMsg: TRegExpr;
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure ReadLine(Line: string; OutputIndex: integer; IsStdErr: boolean;
|
||||||
|
var Handled: boolean); override;
|
||||||
|
class function DefaultSubTool: string; override;
|
||||||
|
end;
|
||||||
|
TDelphiCompilerParserClass = class of TDelphiCompilerParser;
|
||||||
|
|
||||||
|
var
|
||||||
|
IDEDelphiCompilerParser: TDelphiCompilerParserClass = nil;
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure Register;
|
||||||
|
begin
|
||||||
|
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TDelphiCompilerParser }
|
||||||
|
|
||||||
|
constructor TDelphiCompilerParser.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
FRegExprFilenameLineIDMsg:=TRegExpr.Create;
|
||||||
|
FRegExprFilenameLineIDMsg.ModifierStr:='I';
|
||||||
|
// filename(linenumber): E2003 Undeclared identifier: 'foo'
|
||||||
|
FRegExprFilenameLineIDMsg.Expression:='^(.*)\([0-9]+)\): ([HNWEF])([0-9]+) (.*)$';
|
||||||
|
// filename(linenumber): Fatal: F2613 Unit 'Unit3' not found.
|
||||||
|
FRegExprFilenameLineUrgencyIDMsg.Expression:='^(.*)\([0-9]+)\) ([a-zA-Z]+): ([HNWEF])([0-9]+) (.*)$';
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TDelphiCompilerParser.Destroy;
|
||||||
|
begin
|
||||||
|
FreeAndNil(FRegExprFilenameLineIDMsg);
|
||||||
|
FreeAndNil(FRegExprFilenameLineUrgencyIDMsg);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDelphiCompilerParser.ReadLine(Line: string; OutputIndex: integer;
|
||||||
|
IsStdErr: boolean; var Handled: boolean);
|
||||||
|
|
||||||
|
procedure Add(const aFilename, LineNoStr, UrgencyLetter, IDStr, MsgStr: String);
|
||||||
|
var
|
||||||
|
MsgLine: TMessageLine;
|
||||||
|
begin
|
||||||
|
MsgLine:=CreateMsgLine(OutputIndex);
|
||||||
|
case UrgencyLetter of
|
||||||
|
'H': MsgLine.Urgency:=mluHint;
|
||||||
|
'N': MsgLine.Urgency:=mluNote;
|
||||||
|
'W': MsgLine.Urgency:=mluWarning;
|
||||||
|
'E': MsgLine.Urgency:=mluError;
|
||||||
|
'F': MsgLine.Urgency:=mluFatal;
|
||||||
|
else MsgLine.Urgency:=mluImportant;
|
||||||
|
end;
|
||||||
|
MsgLine.Filename:=aFilename;
|
||||||
|
MsgLine.Line:=StrToIntDef(LineNoStr,0);
|
||||||
|
MsgLine.MsgID:=StrToIntDef(IDStr,0);
|
||||||
|
MsgLine.Msg:=MsgStr;
|
||||||
|
if IsStdErr then
|
||||||
|
MsgLine.Flags:=MsgLine.Flags+[mlfStdErr];
|
||||||
|
AddMsgLine(MsgLine);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddFilenameLineIDMsg;
|
||||||
|
var
|
||||||
|
RE: TRegExpr;
|
||||||
|
aFilename, LineNoStr, UrgencyLetter, IDStr, MsgStr: String;
|
||||||
|
begin
|
||||||
|
RE:=FRegExprFilenameLineIDMsg;
|
||||||
|
aFilename:=RE.Match[1];
|
||||||
|
LineNoStr:=RE.Match[2];
|
||||||
|
UrgencyLetter:=RE.Match[3];
|
||||||
|
IDStr:=RE.Match[4];
|
||||||
|
MsgStr:=RE.Match[5];
|
||||||
|
Add(aFilename,LineNoStr,UrgencyLetter,IDStr,MsgStr);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddFilenameLineUrgencyIDMsg;
|
||||||
|
var
|
||||||
|
RE: TRegExpr;
|
||||||
|
aFilename, LineNoStr, UrgencyLetter, IDStr, MsgStr: String;
|
||||||
|
begin
|
||||||
|
RE:=FRegExprFilenameLineUrgencyIDMsg;
|
||||||
|
aFilename:=RE.Match[1];
|
||||||
|
LineNoStr:=RE.Match[2];
|
||||||
|
//UrgencyStr:=RE.Match[3];
|
||||||
|
UrgencyLetter:=RE.Match[4];
|
||||||
|
IDStr:=RE.Match[5];
|
||||||
|
MsgStr:=RE.Match[6];
|
||||||
|
Add(aFilename,LineNoStr,UrgencyLetter,IDStr,MsgStr);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure AddOtherLine;
|
||||||
|
var
|
||||||
|
MsgLine: TMessageLine;
|
||||||
|
begin
|
||||||
|
MsgLine:=CreateMsgLine(OutputIndex);
|
||||||
|
MsgLine.MsgID:=0;
|
||||||
|
MsgLine.SubTool:=SubToolDelphi;
|
||||||
|
if MsgLine.Msg<>'' then
|
||||||
|
MsgLine.Urgency:=mluImportant
|
||||||
|
else
|
||||||
|
MsgLine.Urgency:=mluVerbose2;
|
||||||
|
if IsStdErr then
|
||||||
|
MsgLine.Flags:=MsgLine.Flags+[mlfStdErr];
|
||||||
|
AddMsgLine(MsgLine);
|
||||||
|
end;
|
||||||
|
|
||||||
|
begin
|
||||||
|
FRegExprFilenameLineIDMsg.InputString:=Line;
|
||||||
|
if FRegExprFilenameLineIDMsg.ExecPos(1) then
|
||||||
|
begin
|
||||||
|
AddFilenameLineIDMsg;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
FRegExprFilenameLineUrgencyIDMsg.InputString:=Line;
|
||||||
|
if FRegExprFilenameLineUrgencyIDMsg.ExecPos(1) then
|
||||||
|
begin
|
||||||
|
AddFilenameLineUrgencyIDMsg;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
|
AddOtherLine;
|
||||||
|
|
||||||
|
Handled:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
class function TDelphiCompilerParser.DefaultSubTool: string;
|
||||||
|
begin
|
||||||
|
Result:='dcc';
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user