aboutsummaryrefslogtreecommitdiff
path: root/src/lisp/expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp/expr.rs')
-rw-r--r--src/lisp/expr.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lisp/expr.rs b/src/lisp/expr.rs
index 059113b..934bb4a 100644
--- a/src/lisp/expr.rs
+++ b/src/lisp/expr.rs
@@ -150,11 +150,13 @@ impl fmt::Display for LispExpr {
150 LispExpr::Unit => write!(f, "()")?, 150 LispExpr::Unit => write!(f, "()")?,
151 LispExpr::Number(n) => write!(f, "{}", n)?, 151 LispExpr::Number(n) => write!(f, "{}", n)?,
152 LispExpr::List(l) => { 152 LispExpr::List(l) => {
153 for expr in l.iter() { 153 write!(
154 write!(f, " {} ", expr)? 154 f,
155 } 155 "({})",
156 &l.iter().map(|expr| format!("{}", expr)).collect::<Vec<_>>()[..].join(" ")
157 )?;
156 } 158 }
157 LispExpr::StringLit(s) => write!(f, "{}", s)?, 159 LispExpr::StringLit(s) => write!(f, "{:?}", s)?,
158 LispExpr::Char(c) => write!(f, "{}", c)?, 160 LispExpr::Char(c) => write!(f, "{}", c)?,
159 LispExpr::BoolLit(b) => { 161 LispExpr::BoolLit(b) => {
160 if *b { 162 if *b {
@@ -243,6 +245,7 @@ impl TryFrom<LispExpr> for String {
243 fn try_from(value: LispExpr) -> Result<Self, Self::Error> { 245 fn try_from(value: LispExpr) -> Result<Self, Self::Error> {
244 match value { 246 match value {
245 LispExpr::StringLit(i) => Ok(i), 247 LispExpr::StringLit(i) => Ok(i),
248 LispExpr::Ident(i) => Ok(i),
246 _ => Err(LispError::Eval(EvalError::TypeMismatch)), 249 _ => Err(LispError::Eval(EvalError::TypeMismatch)),
247 } 250 }
248 } 251 }