aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@robocracy.org>2016-04-20 00:45:15 -0400
committerbnewbold <bnewbold@robocracy.org>2016-04-20 00:45:15 -0400
commit495f307ad1b4c467e7b8f67da13932a09a0f2479 (patch)
treea270ecd8363a2ba724f88a324708d2bc1ea79119
parentc92f6f75ac38ede49e6b466da9c2be8da37e1bb9 (diff)
downloadspectrum-495f307ad1b4c467e7b8f67da13932a09a0f2479.zip
spectrum-495f307ad1b4c467e7b8f67da13932a09a0f2479.tar.gz
rust: flush out repr function
-rw-r--r--minimal.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/minimal.rs b/minimal.rs
index 01e64c4..57c8268 100644
--- a/minimal.rs
+++ b/minimal.rs
@@ -126,16 +126,18 @@ fn scheme_eval<'a>(ast: &SchemeExpr) -> Result<SchemeExpr<'a>, &'static str> {
fn scheme_repr<'a>(ast: &SchemeExpr) -> Result<String, &'static str> {
return match ast {
&SchemeExpr::SchemeTrue => Ok("#t".to_string()),
- &SchemeExpr::SchemeFalse => Ok("#t".to_string()),
+ &SchemeExpr::SchemeFalse => Ok("#f".to_string()),
&SchemeExpr::SchemeNull => Ok("'()".to_string()),
+ &SchemeExpr::SchemeBuiltin(b)=> Ok(b.to_string()),
+ &SchemeExpr::SchemeStr(s)=> Ok(s.to_string()),
+ &SchemeExpr::SchemeNum(num) => Ok(format!("{}", num).to_string()),
&SchemeExpr::SchemeList(ref list) => {
let mut ret: String =
list.iter().fold("(".to_string(),
- |acc, ref el| acc + &scheme_repr(&el).unwrap());
- ret.push_str(")");
+ |acc, ref el| acc + " " + &scheme_repr(&el).unwrap());
+ ret.push_str(" )");
Ok(ret)
},
- _ => Err("don't know how to repr something"),
}
}