-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainForm.pas
More file actions
66 lines (52 loc) · 1.24 KB
/
MainForm.pas
File metadata and controls
66 lines (52 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
unit MainForm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TfrmMain = class(TForm)
mmoSource: TMemo;
Button1: TButton;
mmoResult: TMemo;
mmoOutput: TMemo;
procedure Button1Click(Sender: TObject);
private
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
uses
PasToYamlParser;
{$R *.dfm}
procedure TfrmMain.Button1Click(Sender: TObject);
var
parser: TPas2YamlParser;
strm: TMemoryStream;
begin
mmoResult.Clear;
mmoOutput.Clear;
strm := TMemoryStream.Create;
strm.Position := 0;
mmoSource.Lines.SaveToStream(strm, TEncoding.Unicode);
parser := TPas2YamlParser.Create;
parser.OnDebugOutput :=
procedure(const aLine: string)
begin
mmoResult.Lines.Add(aLine);
end;
// parser.OnYamlOutput :=
// procedure(const aLine: string)
// begin
// mmoOutput.Lines.Add(aLine);
// end;
// parser.OnReplaceOutput :=
// procedure(const aSearch, aReplace: string)
// begin
// mmoOutput.Lines.Text := StringReplace(mmoOutput.Lines.Text, aSearch, aReplace, [rfReplaceAll]);
// end;
parser.Run('test', strm);
mmoOutput.Lines.Text := parser.Yaml.Generate('');
end;
end.