Script Refactoring

This commit is contained in:
Michael Schimmel
2026-01-07 11:20:48 +01:00
parent 0d3ccd1c63
commit 108b47e059
+8 -14
View File
@@ -233,7 +233,6 @@ type
// Helpers // Helpers
function ParseTupleBody(StopToken: TTokenKind): TArray<IAstNode>; function ParseTupleBody(StopToken: TTokenKind): TArray<IAstNode>;
function ExtractIdentifiers(const Node: IAstNode; const Context: string): TArray<IIdentifierNode>; function ExtractIdentifiers(const Node: IAstNode; const Context: string): TArray<IIdentifierNode>;
procedure InitSpecialForms;
public public
constructor Create(const ASource: string); constructor Create(const ASource: string);
@@ -498,19 +497,6 @@ constructor TParser.Create(const ASource: string);
begin begin
inherited Create; inherited Create;
FLexer := TLexer.Create(ASource); FLexer := TLexer.Create(ASource);
InitSpecialForms;
NextToken;
end;
destructor TParser.Destroy;
begin
FSpecialForms.Free;
FLexer.Free;
inherited;
end;
procedure TParser.InitSpecialForms;
begin
FSpecialForms := TDictionary<string, TSpecialFormParser>.Create(TStringComparer.Ordinal); FSpecialForms := TDictionary<string, TSpecialFormParser>.Create(TStringComparer.Ordinal);
FSpecialForms.Add('if', ParseIf); FSpecialForms.Add('if', ParseIf);
FSpecialForms.Add('?', ParseCond); FSpecialForms.Add('?', ParseCond);
@@ -526,6 +512,14 @@ begin
FSpecialForms.Add('add-item', ParseAddItem); FSpecialForms.Add('add-item', ParseAddItem);
FSpecialForms.Add('count', ParseCount); FSpecialForms.Add('count', ParseCount);
FSpecialForms.Add('get', ParseGet); FSpecialForms.Add('get', ParseGet);
NextToken;
end;
destructor TParser.Destroy;
begin
FSpecialForms.Free;
FLexer.Free;
inherited;
end; end;
procedure TParser.Error(const Msg: string); procedure TParser.Error(const Msg: string);