From 66171b0802ed3dc445b7af8970c9a757c22e789c Mon Sep 17 00:00:00 2001 From: Michael Schimmel Date: Sun, 8 Mar 2026 13:45:14 +0100 Subject: [PATCH] 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. --- src/ast/parser.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ast/parser.rs b/src/ast/parser.rs index 68cd672..d4e3e42 100644 --- a/src/ast/parser.rs +++ b/src/ast/parser.rs @@ -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,