Fix: Implement ~ and ~@ syntax to prevent parser deadlock

Adds parsing for the `~` (placeholder) and `~@` (splice) syntax.

- `~expr` parses as a placeholder node.
- `~@expr` parses as a splice node.
This commit is contained in:
Michael Schimmel
2026-03-08 13:45:14 +01:00
parent 6f2d9b0e47
commit 66171b0802
+20
View File
@@ -378,6 +378,25 @@ impl<'a> Parser<'a> {
ty: (),
}
}
TokenKind::Tilde => {
let token = self.advance(); // consume ~
if *self.peek() == TokenKind::At {
self.advance(); // consume @
let expr = self.parse_expression();
Node {
identity: NodeIdentity::new(token.location),
kind: UntypedKind::Splice(Box::new(expr)),
ty: (),
}
} else {
let expr = self.parse_expression();
Node {
identity: NodeIdentity::new(token.location),
kind: UntypedKind::Placeholder(Box::new(expr)),
ty: (),
}
}
}
_ => {
self.diagnostics.push_error(
format!(
@@ -386,6 +405,7 @@ impl<'a> Parser<'a> {
),
Some(NodeIdentity::new(self.current_token.location)),
);
self.advance();
Node {
identity: NodeIdentity::new(self.current_token.location),
kind: UntypedKind::Error,