Ast Schema

This commit is contained in:
Michael Schimmel
2026-01-06 14:37:22 +01:00
parent 3b3966b2f7
commit 7313848538
6 changed files with 776 additions and 653 deletions
+3 -1
View File
@@ -42,7 +42,9 @@ uses
Myc.Data.Stream in '..\Src\Data\Myc.Data.Stream.pas',
Myc.Fmx.AstEditor.Handlers.Pipes in '..\Src\AST\Myc.Fmx.AstEditor.Handlers.Pipes.pas',
Demo.Finance in '..\Test\Demo.Finance.pas',
Myc.Ast.Script.Print in '..\Src\AST\Myc.Ast.Script.Print.pas';
Myc.Ast.Script.Print in '..\Src\AST\Myc.Ast.Script.Print.pas',
Myc.Ast.Json.Schema in '..\Src\AST\Myc.Ast.Json.Schema.pas',
Myc.Ast.Attributes in 'Myc.Ast.Attributes.pas';
{$R *.res}
+2
View File
@@ -173,6 +173,8 @@
<DCCReference Include="..\Src\AST\Myc.Fmx.AstEditor.Handlers.Pipes.pas"/>
<DCCReference Include="..\Test\Demo.Finance.pas"/>
<DCCReference Include="..\Src\AST\Myc.Ast.Script.Print.pas"/>
<DCCReference Include="..\Src\AST\Myc.Ast.Json.Schema.pas"/>
<DCCReference Include="Myc.Ast.Attributes.pas"/>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
+14 -6
View File
@@ -43,6 +43,7 @@ uses
Myc.Ast.Environment,
Myc.Ast.RTL,
Myc.Ast.Compiler.Macros,
Myc.Ast.Json.Schema,
// Editor Units
Myc.Fmx.AstEditor,
Demo.Finance,
@@ -286,6 +287,8 @@ begin
CompilerStageBox.BringToFront;
ClearButtonClick(Self);
Memo1.Lines.Text := TAstSchema.GenerateFullSystemPrompt;
end;
procedure TForm1.ShowVizualization;
@@ -1223,24 +1226,29 @@ end;
procedure TForm1.ToJSONButtonClick(Sender: TObject);
var
jsonObj: TJSONObject;
jsonVal: TJSONValue;
converter: IJsonAstConverter;
begin
Memo1.Lines.Clear;
if not Assigned(FCurrExec.Func) then
// Wir prüfen besser direkt, ob der AST da ist, den wir serialisieren wollen
if not Assigned(FCurrUnboundAst) then
begin
Memo1.Lines.Add('No *compiled* AST has been generated yet. Click a test button first.');
Memo1.Lines.Add('No AST has been generated yet. Click a test button first.');
exit;
end;
try
converter := TJsonAstConverter.Create;
jsonObj := converter.Serialize(FCurrUnboundAst);
// Serialize liefert jetzt TJSONValue (Compact Array Format)
jsonVal := converter.Serialize(FCurrUnboundAst);
try
Memo1.Lines.Text := jsonObj.Format(4);
if Assigned(jsonVal) then
Memo1.Lines.Text := jsonVal.Format(4)
else
Memo1.Lines.Text := 'null';
finally
jsonObj.Free;
jsonVal.Free;
end;
except
on E: Exception do