From 14bff1d7bca2b6bc485db6b98cb307d4a322b45e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Sun, 1 Jan 2023 19:40:47 +0100 Subject: [PATCH] AST - Fixed block dump --- src/ast.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index bb580a2..f26be7e 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -93,14 +93,17 @@ impl AstDumper for StmtNode { match self { Self::VarDecl(name, Some(expr)) => format!("( var {} {} )", name.lexeme, expr.dump()), Self::VarDecl(name, None) => format!("( var {} nil )", name.lexeme), - Self::Expression(expr) => format!("( {} )", expr.dump()), + Self::Expression(expr) => format!("{}", expr.dump()), Self::Print(expr) => format!("(print {})", expr.dump()), - Self::Block(stmts) => stmts - .iter() - .map(|s| s.dump()) - .collect::>() - .join(" "), + Self::Block(stmts) => format!( + "( {} )", + stmts + .iter() + .map(|s| s.dump()) + .collect::>() + .join(" ") + ), Self::IfStmt { condition,