1 | unit ModuleBrainfuck;
|
---|
2 |
|
---|
3 | interface
|
---|
4 |
|
---|
5 | uses
|
---|
6 | Classes, SysUtils, ModularSystem, SourceConvertor;
|
---|
7 |
|
---|
8 | type
|
---|
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 |
|
---|
39 | implementation
|
---|
40 |
|
---|
41 | uses
|
---|
42 | CompilerAPI, SourceCodePascal;
|
---|
43 |
|
---|
44 | resourcestring
|
---|
45 | SBrainfuck = 'Brainfuck';
|
---|
46 |
|
---|
47 | { TConvertorBFToPascal }
|
---|
48 |
|
---|
49 | procedure TConvertorBFToPascal.Convert(Input, Output: TSourceList);
|
---|
50 | begin
|
---|
51 | inherited Convert(Input, Output);
|
---|
52 | end;
|
---|
53 |
|
---|
54 | constructor TConvertorBFToPascal.Create;
|
---|
55 | begin
|
---|
56 | inherited;
|
---|
57 | Name := 'BFToPascal';
|
---|
58 | InputType := TSourceBrainfuck;
|
---|
59 | OutputType := TProgram;
|
---|
60 | end;
|
---|
61 |
|
---|
62 | { TConvertorTextToBF }
|
---|
63 |
|
---|
64 | procedure TConvertorTextToBF.Convert(Input, Output: TSourceList);
|
---|
65 | begin
|
---|
66 | inherited Convert(Input, Output);
|
---|
67 | end;
|
---|
68 |
|
---|
69 | constructor TConvertorTextToBF.Create;
|
---|
70 | begin
|
---|
71 | inherited;
|
---|
72 | Name := 'TextToBF';
|
---|
73 | InputType := TSourceFileLink;
|
---|
74 | OutputType := TSourceBrainfuck;
|
---|
75 | end;
|
---|
76 |
|
---|
77 | { TModuleBrainfuck }
|
---|
78 |
|
---|
79 | constructor TModuleBrainfuck.Create;
|
---|
80 | begin
|
---|
81 | inherited;
|
---|
82 | Name := 'Brainfuck';
|
---|
83 | Title := SBrainfuck;
|
---|
84 | Dependencies.Add('Pascal');
|
---|
85 | end;
|
---|
86 |
|
---|
87 | procedure TModuleBrainfuck.DoInstall;
|
---|
88 | begin
|
---|
89 | inherited;
|
---|
90 | TCompilerAPI(API).RegisterConvertor(TConvertorTextToBF);
|
---|
91 | TCompilerAPI(API).RegisterConvertor(TConvertorBFToPascal);
|
---|
92 | end;
|
---|
93 |
|
---|
94 | procedure TModuleBrainfuck.DoUninstall;
|
---|
95 | begin
|
---|
96 | TCompilerAPI(API).UnregisterConvertor(TConvertorTextToBF);
|
---|
97 | TCompilerAPI(API).UnregisterConvertor(TConvertorBFToPascal);
|
---|
98 | inherited;
|
---|
99 | end;
|
---|
100 |
|
---|
101 | end.
|
---|
102 |
|
---|