diff --git a/src/main.rs b/src/main.rs index 9062b55..e2e2618 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,9 @@ fn main() { // Everything is in a List(..) so we need to get it out and make it into // a vector of Expr instead, so we can compile it. let a = util::unwrap_list_nest(ast.unwrap()); - println!("{:#?}", a); + for e in a.iter() { + println!("{}", e); + } // TODO: compile to something else.. } } diff --git a/src/token.rs b/src/token.rs index fadd65c..6d1d3eb 100644 --- a/src/token.rs +++ b/src/token.rs @@ -20,22 +20,10 @@ impl std::fmt::Display for Expr { Expr::Null => write!(f, "Null"), Expr::Bool(b) => write!(f, "{}", b), Expr::Number(n) => write!(f, "{}", n), - Expr::String(s) => write!(f, "{}", unescape(s.to_string())), + Expr::String(s) => write!(f, "\"{}\"", unescape(s.to_string())), Expr::Symbol(s) => write!(f, "{}", s), - Expr::List(l, _) => { - write!(f, "(")?; - for e in l.iter() { - write!(f, "{}", e)?; - } - write!(f, ")") - } - Expr::Vector(l, _) => { - write!(f, "[")?; - for e in l.iter() { - write!(f, "{}", e)?; - } - write!(f, "]") - } + Expr::List(l, _) => write!(f, "({})", l.iter().map(|e| format!("{}", e)).collect::>().join(" ")), + Expr::Vector(l, _) => write!(f, "[{}]", l.iter().map(|e| format!("{}", e)).collect::>().join(", ")), } } }