source: trunk/Compiler/Modules/Brainfuck/ModuleBrainfuck.pas

Last change on this file was 75, checked in by chronos, 6 months ago
  • Modified: Removed U prefix from unit names.
  • Modified: Updated Common package.
File size: 2.0 KB
Line 
1unit ModuleBrainfuck;
2
3interface
4
5uses
6 Classes, SysUtils, ModularSystem, SourceConvertor;
7
8type
9 TBrainFuckCommand = (cmNoOperation, cmInc, cmDec, cmPointerInc, cmPointerDec,
10 cmOutput, cmInput, cmLoopStart, cmLoopEnd, cmDebug);
11
12 TSourceBrainfuck = class(TSource)
13 Code: array of TBrainFuckCommand;
14 end;
15
16 { TConvertorTextToBF }
17
18 TConvertorTextToBF = class(TConvertor)
19 procedure Convert(Input, Output: TSourceList); override;
20 constructor Create; override;
21 end;
22
23 { TConvertorBFToPascal }
24
25 TConvertorBFToPascal = class(TConvertor)
26 procedure Convert(Input, Output: TSourceList); override;
27 constructor Create; override;
28 end;
29
30 { TModuleBrainfuck }
31
32 TModuleBrainfuck = class(TModule)
33 constructor Create(AOwner: TComponent); override;
34 procedure DoInstall; override;
35 procedure DoUninstall; override;
36 end;
37
38
39implementation
40
41uses
42 CompilerAPI, SourceCodePascal;
43
44resourcestring
45 SBrainfuck = 'Brainfuck';
46
47{ TConvertorBFToPascal }
48
49procedure TConvertorBFToPascal.Convert(Input, Output: TSourceList);
50begin
51 inherited Convert(Input, Output);
52end;
53
54constructor TConvertorBFToPascal.Create;
55begin
56 inherited;
57 Name := 'BFToPascal';
58 InputType := TSourceBrainfuck;
59 OutputType := TProgram;
60end;
61
62{ TConvertorTextToBF }
63
64procedure TConvertorTextToBF.Convert(Input, Output: TSourceList);
65begin
66 inherited Convert(Input, Output);
67end;
68
69constructor TConvertorTextToBF.Create;
70begin
71 inherited;
72 Name := 'TextToBF';
73 InputType := TSourceFileLink;
74 OutputType := TSourceBrainfuck;
75end;
76
77{ TModuleBrainfuck }
78
79constructor TModuleBrainfuck.Create;
80begin
81 inherited;
82 Name := 'Brainfuck';
83 Title := SBrainfuck;
84 Dependencies.Add('Pascal');
85end;
86
87procedure TModuleBrainfuck.DoInstall;
88begin
89 inherited;
90 TCompilerAPI(API).RegisterConvertor(TConvertorTextToBF);
91 TCompilerAPI(API).RegisterConvertor(TConvertorBFToPascal);
92end;
93
94procedure TModuleBrainfuck.DoUninstall;
95begin
96 TCompilerAPI(API).UnregisterConvertor(TConvertorTextToBF);
97 TCompilerAPI(API).UnregisterConvertor(TConvertorBFToPascal);
98 inherited;
99end;
100
101end.
102
Note: See TracBrowser for help on using the repository browser.