From 0e2572092711ac8dcc50a2639c1284e8d6a2ab23 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 21 Dec 2017 01:11:16 -0800 Subject: [PATCH] Fixing quote --- src/rukka_lang/mod.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/rukka_lang/mod.rs b/src/rukka_lang/mod.rs index 9f42e24..9d15006 100644 --- a/src/rukka_lang/mod.rs +++ b/src/rukka_lang/mod.rs @@ -100,7 +100,10 @@ impl EvaluatorState { fn eval_special_form(&mut self, form: &str, operands: Sexp) -> Result { use self::Sexp::*; Ok(match form { - "quote" => operands, //TODO Broken + "quote" => match operands { + Cons(box quoted, box Nil) => quoted, + _ => return Err(format!("Bad syntax in quote")), + }, "eq?" => match operands { Cons(box lhs, box Cons(box rhs, _)) => { match lhs == rhs { @@ -307,7 +310,7 @@ fn parse(tokens: &mut Peekable>) -> Result { Some(RParen) => Err(format!("Unexpected ')'")), Some(Quote) => { let quoted = parse(tokens)?; - Ok(Cons(Box::new(SymbolAtom(format!("quote"))), Box::new(quoted))) + Ok(Cons(Box::new(SymbolAtom(format!("quote"))), Box::new(Cons(Box::new(quoted), Box::new(Nil))))) }, Some(NumLiteral(n)) => Ok(NumberAtom(n)), None => Err(format!("Unexpected end of input")),