source: trunk/Compiler/Modules/XML/TargetXML.pas

Last change on this file was 77, checked in by chronos, 6 months ago
  • Modified: Compiler targets moved into modules.
File size: 2.2 KB
Line 
1unit TargetXML;
2
3interface
4
5uses
6 Classes, SysUtils, Target, Producer, SourceCodePascal;
7
8type
9
10 { TTargetXML }
11
12 TTargetXML = class(TTarget)
13 constructor Create; override;
14 end;
15
16 { TProducerXML }
17
18 TProducerXML = class(TProducer)
19 private
20 procedure GenerateModule(Module: TSourceModule);
21 procedure GenerateUnit(Module: TSourceModule);
22 procedure GenerateLibrary(Module: TSourceModule);
23 procedure GeneratePackage(Module: TSourceModule);
24 public
25 procedure AssignToStringList(Target: TStringList); override;
26 procedure Produce(Module: TSourceModule); override;
27 end;
28
29
30implementation
31
32{ TProducerXML }
33
34procedure TProducerXML.GenerateModule(Module: TSourceModule);
35begin
36 Module.TargetFile := Module.Name + '.xml';
37 if Module is TModuleProgram then
38 with TModuleProgram(Module) do begin
39 EmitLn('<?xml version="1.0"?>');
40 EmitLn('<program>');
41 //GenerateUses(UsedModules);
42 //GenerateCommonBlockImplementation(Body, '');
43 EmitLn('</program>');
44 end;
45 if Module is TModuleUnit then GenerateUnit(Module)
46 else if Module is TModuleLibrary then GenerateLibrary(Module)
47 else if Module is TModulePackage then GeneratePackage(Module);
48end;
49
50procedure TProducerXML.GenerateUnit(Module: TSourceModule);
51begin
52 EmitLn('<?xml version="1.0"?>');
53 EmitLn('<unit>');
54 //GenerateUses(UsedModules);
55 //GenerateCommonBlockImplementation(Body, '');
56 EmitLn('</unit');
57end;
58
59procedure TProducerXML.GenerateLibrary(Module: TSourceModule);
60begin
61 EmitLn('<?xml version="1.0"?>');
62 EmitLn('<library>');
63 //GenerateUses(UsedModules);
64 //GenerateCommonBlockImplementation(Body, '');
65 EmitLn('</library>');
66end;
67
68procedure TProducerXML.GeneratePackage(Module: TSourceModule);
69begin
70 EmitLn('<?xml version="1.0"?>');
71 EmitLn('<package>');
72 //GenerateUses(UsedModules);
73 //GenerateCommonBlockImplementation(Body, '');
74 EmitLn('</package>');
75end;
76
77procedure TProducerXML.Produce(Module: TSourceModule);
78begin
79 GenerateModule(Module);
80end;
81
82procedure TProducerXML.AssignToStringList(Target: TStringList);
83begin
84 Target.Assign(TextSource);
85end;
86
87{ TTargetXML }
88
89constructor TTargetXML.Create;
90begin
91 inherited;
92 SysName := 'XML';
93 Name := 'XML';
94 Producer := TProducerXML.Create;
95end;
96
97end.
98
Note: See TracBrowser for help on using the repository browser.