Adding Pipes

This commit is contained in:
Michael Schimmel
2025-12-18 11:21:18 +01:00
parent 0b015fe4e7
commit 8bde31a478
10 changed files with 865 additions and 31 deletions
+67
View File
@@ -1,3 +1,6 @@
//==================================================================================================
//== FULL UNIT START: Myc.Ast (from Myc.Ast.pas)
//==================================================================================================
unit Myc.Ast;
interface
@@ -327,6 +330,27 @@ type
const AStaticType: IStaticType = nil
): ISeriesLengthNode; overload; static;
// --- PIPES ---
class function PipeInput(
const AStream: IIdentifierNode;
const ASelector: IKeywordNode = nil;
const Loc: ISourceLocation = nil
): IPipeInputNode; static;
class function Pipe(
const AInputs: TArray<IPipeInputNode>;
const ATransformation: ILambdaExpressionNode;
const Loc: ISourceLocation = nil
): IPipeNode; overload; static;
class function Pipe(
const Identity: IAstIdentity;
const AInputs: IPipeInputList;
const ATransformation: ILambdaExpressionNode;
const AStaticType: IStaticType = nil
): IPipeNode; overload; static;
end;
implementation
@@ -909,4 +933,47 @@ begin
);
end;
// --- PIPES ---
class function TAst.PipeInput(const AStream: IIdentifierNode; const ASelector: IKeywordNode; const Loc: ISourceLocation): IPipeInputNode;
begin
var id := TIdentities.Structural(Loc);
// Erzeugt Node aus Myc.Ast.Nodes
Result := TPipeInputNode.Create(AStream, ASelector, id, TTypes.Unknown);
end;
class function TAst.Pipe(
const AInputs: TArray<IPipeInputNode>;
const ATransformation: ILambdaExpressionNode;
const Loc: ISourceLocation
): IPipeNode;
begin
var listId := TIdentities.List('[', ']', ' ', Loc);
var inputList := TPipeInputList.Create(AInputs, listId);
var id := TIdentities.Structural(Loc);
// Erzeugt Node aus Myc.Ast.Nodes
Result := TPipeNode.Create(inputList, ATransformation, id, TTypes.Unknown);
end;
class function TAst.Pipe(
const Identity: IAstIdentity;
const AInputs: IPipeInputList;
const ATransformation: ILambdaExpressionNode;
const AStaticType: IStaticType
): IPipeNode;
begin
Result :=
TPipeNode.Create(
AInputs,
ATransformation,
Identity,
if AStaticType <> nil then AStaticType
else TTypes.Unknown
);
end;
end.
//==================================================================================================
//== FULL UNIT END: Myc.Ast
//==================================================================================================