From 25527bbdf0e0dd5740d5cf44d329c5821a21e38e Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 11 Dec 2017 01:53:27 -0800 Subject: [PATCH] Add fn literal variant --- src/rukka_lang/mod.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rukka_lang/mod.rs b/src/rukka_lang/mod.rs index ee977bb..c42d79c 100644 --- a/src/rukka_lang/mod.rs +++ b/src/rukka_lang/mod.rs @@ -70,6 +70,7 @@ impl ProgrammingLanguageInterface for Rukka { impl EvaluatorState { fn eval(&mut self, expr: Sexp) -> Result { use self::Sexp::*; + println!("Evaling {:?}", expr); Ok(match expr { SymbolAtom(ref sym) => match self.get_var(sym) { Some(ref sexp) => { @@ -78,6 +79,7 @@ impl EvaluatorState { }, None => return Err(format!("Variable {} not bound", sym)), }, + expr @ FnLiteral { .. } => expr, expr @ StringAtom(_) => expr, expr @ NumberAtom(_) => expr, True => True, @@ -97,7 +99,7 @@ impl EvaluatorState { fn eval_special_form(&mut self, form: &str, operands: Sexp) -> Result { use self::Sexp::*; Ok(match form { - "quote" => operands, + "quote" => operands, //TODO Broken "eq?" => match operands { Cons(box lhs, box Cons(box rhs, _)) => { match lhs == rhs { @@ -190,7 +192,11 @@ enum Sexp { True, False, Cons(Box, Box), - Nil + Nil, + FnLiteral { + formal_params: Vec, + body: Box + } } impl Sexp { @@ -204,6 +210,7 @@ impl Sexp { &NumberAtom(ref n) => format!("{}", n), &Cons(ref car, ref cdr) => format!("({} . {})", car.print(), cdr.print()), &Nil => format!("()"), + &FnLiteral { ref formal_params, .. } => format!("", formal_params), } }