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:
Michael Schimmel
2026-03-01 21:52:10 +01:00
parent a98e51c762
commit 50f33b2c30
14 changed files with 169 additions and 4 deletions
+16
View File
@@ -137,6 +137,7 @@ impl<'a> Parser<'a> {
match sym.name.as_ref() {
"if" => self.parse_if(identity),
"fn" => self.parse_fn(identity),
"pipe" => self.parse_pipe(identity),
"again" => self.parse_again(identity),
"def" => self.parse_def(identity),
"assign" => self.parse_assign(identity),
@@ -229,6 +230,21 @@ impl<'a> Parser<'a> {
})
}
fn parse_pipe(&mut self, identity: Identity) -> Result<Node<UntypedKind>, String> {
let inputs_node = self.parse_expression()?;
let inputs = match inputs_node.kind {
UntypedKind::Tuple { elements } => elements,
_ => vec![inputs_node],
};
let lambda = Box::new(self.parse_expression()?);
Ok(Node {
identity,
kind: UntypedKind::Pipe { inputs, lambda },
ty: (),
})
}
fn parse_fn(&mut self, identity: Identity) -> Result<Node<UntypedKind>, String> {
let params = Box::new(self.parse_param_vector()?);
let body = self.parse_expression()?;