From 63aa82a1cdaf0a80160eae22b00a1651e8e93c2f Mon Sep 17 00:00:00 2001 From: Ryan Chandler Date: Fri, 16 Sep 2022 10:26:11 +0100 Subject: [PATCH] parser: support variable variables --- trunk_parser/src/parser/mod.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/trunk_parser/src/parser/mod.rs b/trunk_parser/src/parser/mod.rs index 5200fa1..ca0693f 100644 --- a/trunk_parser/src/parser/mod.rs +++ b/trunk_parser/src/parser/mod.rs @@ -1933,7 +1933,7 @@ impl Parser { TokenKind::Dollar => { self.next(); - match self.current.kind { + match &self.current.kind { TokenKind::LeftBrace => { self.next(); @@ -1945,6 +1945,15 @@ impl Parser { name: Box::new(name), } } + TokenKind::Variable(variable) => { + let variable = variable.clone(); + + self.next(); + + Expression::DynamicVariable { + name: Box::new(Expression::Variable { name: variable }), + } + } _ => todo!(), } } @@ -4240,6 +4249,16 @@ mod tests { ); } + #[test] + fn variable_variables() { + assert_ast( + "