Skip to content

Commit

Permalink
Update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanYankovsky committed Sep 17, 2014
1 parent 126c3fc commit a2219a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Demo/uMainForm.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ object Form1: TForm1
Width = 666
Height = 389
Align = alClient
Lines.Strings = (
'Memo1')
ScrollBars = ssBoth
TabOrder = 0
end
Expand Down
13 changes: 9 additions & 4 deletions Demo/uMainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ implementation

function Parse(const Content: string): string;
var
Define: string;
ASTBuilder: TPasSyntaxTreeBuilder;
StringStream: TStringStream;
SyntaxTree: TSyntaxNode;
Expand All @@ -44,6 +43,9 @@ function Parse(const Content: string): string;

ASTBuilder := TPasSyntaxTreeBuilder.Create;
try
ASTBuilder.AddDefine('MSWINDOWS');
ASTBuilder.AddDefine('WIN32');

SyntaxTree := ASTBuilder.Run(StringStream);
try
Result := TSyntaxTreeWriter.ToXML(SyntaxTree);
Expand All @@ -61,16 +63,19 @@ function Parse(const Content: string): string;
procedure TForm1.OpenDelphiUnit1Click(Sender: TObject);
var
SL: TStringList;
ParserStr: string;
Col, Line: Integer;
begin
if OpenDialog1.Execute then
begin
SL := TStringList.Create;
try
SL.LoadFromFile(OpenDialog1.FileName);

Memo1.Lines.Text := FormatXMLData(Parse(SL.Text));
try
Memo1.Lines.Text := FormatXMLData(Parse(SL.Text));
except
on E: EParserException do
Memo1.Lines.Add(Format('[%d, %d] %s', [E.Line, E.Col, E.Message]));
end;
finally
SL.Free;
end;
Expand Down

0 comments on commit a2219a0

Please sign in to comment.