1 {
2 ***************************************************************************
3 * *
4 * This source is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This code is distributed in the hope that it will be useful, but *
10 * WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * General Public License for more details. *
13 * *
14 * A copy of the GNU General Public License is available on the World *
15 * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
16 * obtain it by writing to the Free Software Foundation, *
17 * Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA. *
18 * *
19 ***************************************************************************
20
21 Author: Mattias Gaertner
22
23 Abstract:
24 Parser for Free Pascal Compiler output.
25 }
26 unit etPas2jsMsgParser;
27
28 {$mode objfpc}{$H+}
29
30 interface
31
32 uses
33 Classes, SysUtils,
34 IDEExternToolIntf, LazFileUtils,
35 etFPCMsgParser, EnvironmentOpts;
36
37 type
38
39 { TPas2jsMsgFilePool }
40
41 TPas2jsMsgFilePool = class(TFPCMsgFilePool)
42 public
43 destructor Destroy; override;
LoadCurrentEnglishFilenull44 function LoadCurrentEnglishFile(UpdateFromDisk: boolean; AThread: TThread
45 ): TFPCMsgFilePoolItem; override;
46 procedure GetMsgFileNames({%H-}CompilerFilename, {%H-}TargetOS, {%H-}TargetCPU: string;
47 out anEnglishFile, aTranslationFile: string); override;
48 end;
49
50 { TIDEPas2jsParser }
51
52 TIDEPas2jsParser = class(TIDEFPCParser)
53 protected
ToUTF8null54 function ToUTF8(const Line: string): string; override;
55 public
CanParseSubToolnull56 class function CanParseSubTool(const SubTool: string): boolean; override;
DefaultSubToolnull57 class function DefaultSubTool: string; override;
Prioritynull58 class function Priority: integer; override;
MsgFilePoolnull59 class function MsgFilePool: TFPCMsgFilePool; override;
60 end;
61
62 var
63 Pas2jsMsgFilePool: TFPCMsgFilePool = nil;
64
65 procedure RegisterPas2jsParser;
66
67 implementation
68
69 procedure RegisterPas2jsParser;
70 begin
71 ExternalToolList.RegisterParser(TIDEPas2jsParser);
72 end;
73
74 { TPas2jsMsgFilePool }
75
76 destructor TPas2jsMsgFilePool.Destroy;
77 begin
78 inherited Destroy;
79 if Pas2jsMsgFilePool=Self then
80 Pas2jsMsgFilePool:=nil;
81 end;
82
TPas2jsMsgFilePool.LoadCurrentEnglishFilenull83 function TPas2jsMsgFilePool.LoadCurrentEnglishFile(UpdateFromDisk: boolean;
84 AThread: TThread): TFPCMsgFilePoolItem;
85 var
86 Filename: String;
87 begin
88 Result:=nil;
89 Filename:=AppendPathDelim(EnvironmentOptions.GetParsedLazarusDirectory)+'ide'+PathDelim+'pas2jsmsg.txt';
90 if not FilenameIsAbsolute(Filename) then exit;
91 Result:=LoadFile(Filename,UpdateFromDisk,AThread);
92 end;
93
94 procedure TPas2jsMsgFilePool.GetMsgFileNames(CompilerFilename, TargetOS,
95 TargetCPU: string; out anEnglishFile, aTranslationFile: string);
96 begin
97 anEnglishFile:=AppendPathDelim(EnvironmentOptions.GetParsedLazarusDirectory)+'ide'+PathDelim+'pas2jsmsg.txt';
98 aTranslationFile:='';
99 end;
100
101 { TIDEPas2jsParser }
102
TIDEPas2jsParser.ToUTF8null103 function TIDEPas2jsParser.ToUTF8(const Line: string): string;
104 begin
105 Result:=Line;
106 end;
107
TIDEPas2jsParser.CanParseSubToolnull108 class function TIDEPas2jsParser.CanParseSubTool(const SubTool: string): boolean;
109 begin
110 Result:=(CompareText(SubTool,SubToolPas2js)=0);
111 end;
112
TIDEPas2jsParser.DefaultSubToolnull113 class function TIDEPas2jsParser.DefaultSubTool: string;
114 begin
115 Result:=SubToolPas2js;
116 end;
117
TIDEPas2jsParser.Prioritynull118 class function TIDEPas2jsParser.Priority: integer;
119 begin
120 Result:=SubToolPas2jsPriority;
121 end;
122
TIDEPas2jsParser.MsgFilePoolnull123 class function TIDEPas2jsParser.MsgFilePool: TFPCMsgFilePool;
124 begin
125 Result:=Pas2jsMsgFilePool;
126 end;
127
128 initialization
129 IDEPas2jsParser:=TIDEPas2jsParser;
130 finalization
131 FreeAndNil(Pas2jsMsgFilePool);
132
133 end.
134
135