Feat: Add Pipe Node
Introduces a new `Pipe` node to the Abstract Syntax Tree (AST). This node represents a functional composition pattern, allowing for chaining of operations. The changes include: - Defining the `Pipe` variant in `BoundKind` and `UntypedKind`. - Implementing parsing logic for the `pipe` keyword. - Adding handling for the `Pipe` node in various compiler passes (analyzer, binder, captures, dumper, macros, optimizer, TCO, type checker). - Including a placeholder implementation for `Pipe` execution in the VM. - Updating integration tests to use the new `pipe` syntax.
This commit is contained in:
@@ -152,6 +152,22 @@ impl<E: MacroEvaluator> MacroExpander<E> {
|
||||
})
|
||||
}
|
||||
|
||||
UntypedKind::Pipe { inputs, lambda } => {
|
||||
let mut expanded_inputs = Vec::with_capacity(inputs.len());
|
||||
for input in inputs {
|
||||
expanded_inputs.push(self.expand_recursive(input)?);
|
||||
}
|
||||
let expanded_lambda = Box::new(self.expand_recursive(*lambda)?);
|
||||
Ok(Node {
|
||||
identity: node.identity,
|
||||
kind: UntypedKind::Pipe {
|
||||
inputs: expanded_inputs,
|
||||
lambda: expanded_lambda,
|
||||
},
|
||||
ty: (),
|
||||
})
|
||||
}
|
||||
|
||||
UntypedKind::Lambda { params, body } => {
|
||||
self.registry.push();
|
||||
let expanded_params = self.expand_recursive(*params)?;
|
||||
@@ -498,6 +514,22 @@ impl<E: MacroEvaluator> MacroExpander<E> {
|
||||
})
|
||||
}
|
||||
|
||||
UntypedKind::Pipe { inputs, lambda } => {
|
||||
let mut expanded_inputs = Vec::with_capacity(inputs.len());
|
||||
for input in inputs {
|
||||
expanded_inputs.push(self.expand_template(input, state)?);
|
||||
}
|
||||
let expanded_lambda = Box::new(self.expand_template(*lambda, state)?);
|
||||
Ok(Node {
|
||||
identity: node.identity,
|
||||
kind: UntypedKind::Pipe {
|
||||
inputs: expanded_inputs,
|
||||
lambda: expanded_lambda,
|
||||
},
|
||||
ty: (),
|
||||
})
|
||||
}
|
||||
|
||||
UntypedKind::Lambda { params, body } => {
|
||||
let expanded_params = self.expand_template(*params, state)?;
|
||||
let body = self.expand_template(Node::clone(&body), state)?;
|
||||
|
||||
Reference in New Issue
Block a user