mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
fix: better list & vector fmt
This commit is contained in:
parent
af2299e78f
commit
c03ec9e5f4
|
@ -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..
|
||||
}
|
||||
}
|
||||
|
|
18
src/token.rs
18
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::<Vec<String>>().join(" ")),
|
||||
Expr::Vector(l, _) => write!(f, "[{}]", l.iter().map(|e| format!("{}", e)).collect::<Vec<String>>().join(", ")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue