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
+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