diff --git a/src/executor.rs b/src/executor.rs index bc64881..afe618d 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -25,11 +25,24 @@ impl fmt::Display for LispValue { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { LispValue::Nil => write!(f, "nil"), - LispValue::String(str) => write!(f, "{}", str), - LispValue::LispFunction(name, _) => write!(f, "<'{}': Lisp Function>", name), - LispValue::RustFunction(name, _) => write!(f, "<'{}': Rust Function>", name), + LispValue::String(str) => write!(f, "\"{}\"", str), + LispValue::LispFunction(name, _) => write!(f, "", name), + LispValue::RustFunction(name, _) => write!(f, "", name), LispValue::Integer(num) => write!(f, "{}", num), LispValue::Float(num) => write!(f, "{}", num), + LispValue::List(elems, quoted) => { + let mut strs = Vec::new(); + + for e in elems { + strs.push(e.to_string()); + } + + if *quoted { + write!(f, "'({})", strs.join(", ")) + } else { + write!(f, "({})", strs.join(", ")) + } + }, val => { write!(f, "{}", format!("{:?}", val)) } diff --git a/src/test.lisp b/src/test.lisp index c1b62fc..e63d04e 100644 --- a/src/test.lisp +++ b/src/test.lisp @@ -1,14 +1,13 @@ ; This is a comment -(print - (add 0.5 3) +(print "Hello, world!") + +(print (1 2 3)) + +(print + (add 15 105.3) ) -; LispValue::List({ -; LispValue::RustFunction("print", ), -; LispValue::List({ -; LispValue::RustFunction("add", ), -; LispValue::Float(1.0), -; LispValue::Integer(3) -; }) -; }) \ No newline at end of file +(print + '(add 15 105.3) +)