AST - Fixed block dump
This commit is contained in:
parent
d8888fd15f
commit
14bff1d7bc
1 changed files with 9 additions and 6 deletions
15
src/ast.rs
15
src/ast.rs
|
@ -93,14 +93,17 @@ impl AstDumper for StmtNode {
|
||||||
match self {
|
match self {
|
||||||
Self::VarDecl(name, Some(expr)) => format!("( var {} {} )", name.lexeme, expr.dump()),
|
Self::VarDecl(name, Some(expr)) => format!("( var {} {} )", name.lexeme, expr.dump()),
|
||||||
Self::VarDecl(name, None) => format!("( var {} nil )", name.lexeme),
|
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::Print(expr) => format!("(print {})", expr.dump()),
|
||||||
|
|
||||||
Self::Block(stmts) => stmts
|
Self::Block(stmts) => format!(
|
||||||
.iter()
|
"( {} )",
|
||||||
.map(|s| s.dump())
|
stmts
|
||||||
.collect::<Vec<String>>()
|
.iter()
|
||||||
.join(" "),
|
.map(|s| s.dump())
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(" ")
|
||||||
|
),
|
||||||
|
|
||||||
Self::IfStmt {
|
Self::IfStmt {
|
||||||
condition,
|
condition,
|
||||||
|
|
Loading…
Reference in a new issue