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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user