Fixed macro def expansion

This commit is contained in:
Michael Schimmel
2025-11-05 10:39:15 +01:00
parent edd3e83377
commit 60358365cd
6 changed files with 11 additions and 53 deletions
-17
View File
@@ -46,8 +46,6 @@ type
// --- Standard Traversal (Use inherited) ---
function VisitKeyword(const Node: IKeywordNode): IAstNode; override;
function VisitMacroDefinition(const Node: IMacroDefinitionNode): IAstNode; override;
function VisitMacroExpansionNode(const Node: IMacroExpansionNode): IAstNode; override;
function VisitRecurNode(const Node: IRecurNode): IAstNode; override;
function VisitConstant(const Node: IConstantNode): IAstNode; override;
function VisitCreateSeries(const Node: ICreateSeriesNode): IAstNode; override;
@@ -171,21 +169,6 @@ begin
end;
end;
function TAstBinder.VisitMacroDefinition(const Node: IMacroDefinitionNode): IAstNode;
begin
// Macros are compile-time only. The Binder (Phase 2) should not see them.
raise Exception.Create('TMyAstBinder: MacroDefinition node encountered.');
end;
function TAstBinder.VisitMacroExpansionNode(const Node: IMacroExpansionNode): IAstNode;
begin
// The MacroExpander (Phase 1) created this node.
// We must bind the ExpandedBody, but keep the MacroExpansionNode wrapper.
// The base TAstTransformer implementation already does exactly this
// by visiting Callee, Arguments, and ExpandedBody.
Result := inherited VisitMacroExpansionNode(Node);
end;
function TAstBinder.VisitFunctionCall(const Node: IFunctionCallNode): IAstNode;
begin
// --- Transformation: Keyword-as-Function ---