1 | unit TargetXML;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, Target, Producer, SourceCodePascal;
|
---|
7 |
|
---|
8 | type
|
---|
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 |
|
---|
30 | implementation
|
---|
31 |
|
---|
32 | { TProducerXML }
|
---|
33 |
|
---|
34 | procedure TProducerXML.GenerateModule(Module: TSourceModule);
|
---|
35 | begin
|
---|
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);
|
---|
48 | end;
|
---|
49 |
|
---|
50 | procedure TProducerXML.GenerateUnit(Module: TSourceModule);
|
---|
51 | begin
|
---|
52 | EmitLn('<?xml version="1.0"?>');
|
---|
53 | EmitLn('<unit>');
|
---|
54 | //GenerateUses(UsedModules);
|
---|
55 | //GenerateCommonBlockImplementation(Body, '');
|
---|
56 | EmitLn('</unit');
|
---|
57 | end;
|
---|
58 |
|
---|
59 | procedure TProducerXML.GenerateLibrary(Module: TSourceModule);
|
---|
60 | begin
|
---|
61 | EmitLn('<?xml version="1.0"?>');
|
---|
62 | EmitLn('<library>');
|
---|
63 | //GenerateUses(UsedModules);
|
---|
64 | //GenerateCommonBlockImplementation(Body, '');
|
---|
65 | EmitLn('</library>');
|
---|
66 | end;
|
---|
67 |
|
---|
68 | procedure TProducerXML.GeneratePackage(Module: TSourceModule);
|
---|
69 | begin
|
---|
70 | EmitLn('<?xml version="1.0"?>');
|
---|
71 | EmitLn('<package>');
|
---|
72 | //GenerateUses(UsedModules);
|
---|
73 | //GenerateCommonBlockImplementation(Body, '');
|
---|
74 | EmitLn('</package>');
|
---|
75 | end;
|
---|
76 |
|
---|
77 | procedure TProducerXML.Produce(Module: TSourceModule);
|
---|
78 | begin
|
---|
79 | GenerateModule(Module);
|
---|
80 | end;
|
---|
81 |
|
---|
82 | procedure TProducerXML.AssignToStringList(Target: TStringList);
|
---|
83 | begin
|
---|
84 | Target.Assign(TextSource);
|
---|
85 | end;
|
---|
86 |
|
---|
87 | { TTargetXML }
|
---|
88 |
|
---|
89 | constructor TTargetXML.Create;
|
---|
90 | begin
|
---|
91 | inherited;
|
---|
92 | SysName := 'XML';
|
---|
93 | Name := 'XML';
|
---|
94 | Producer := TProducerXML.Create;
|
---|
95 | end;
|
---|
96 |
|
---|
97 | end.
|
---|
98 |
|
---|