From f6d047e3b8399b1afc2d02f55ee717b6b9216053 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 7 Dec 2017 19:51:34 -0800 Subject: [PATCH] True and False primitives --- src/rukka_lang/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rukka_lang/mod.rs b/src/rukka_lang/mod.rs index 1b25158..13cbbb3 100644 --- a/src/rukka_lang/mod.rs +++ b/src/rukka_lang/mod.rs @@ -53,6 +53,8 @@ impl EvaluatorState { SymbolAtom(sym) => unimplemented!(), expr @ StringAtom(_) => expr, expr @ NumberAtom(_) => expr, + True => True, + False => False, Cons(box operator, box operands) => { match operator { SymbolAtom(ref sym) => match &sym[..] { @@ -116,6 +118,8 @@ enum Sexp { SymbolAtom(String), StringAtom(String), NumberAtom(u64), + True, + False, Cons(Box, Box), Nil } @@ -124,6 +128,8 @@ impl Sexp { fn print(&self) -> String { use self::Sexp::*; match self { + &True => format!("#t"), + &False => format!("#f"), &SymbolAtom(ref sym) => format!("{}", sym), &StringAtom(ref s) => format!("\"{}\"", s), &NumberAtom(ref n) => format!("{}", n), @@ -179,6 +185,8 @@ fn parse(tokens: &mut Peekable>) -> Result { use self::Token::*; use self::Sexp::*; match tokens.next() { + Some(Word(ref s)) if s == "#f" => Ok(False), + Some(Word(ref s)) if s == "#t" => Ok(True), Some(Word(s)) => Ok(SymbolAtom(s)), Some(StringLiteral(s)) => Ok(StringAtom(s)), Some(LParen) => parse_sexp(tokens),