aboutsummaryrefslogtreecommitdiffstats
path: root/src/cexpr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cexpr.rs')
-rw-r--r--src/cexpr.rs20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/cexpr.rs b/src/cexpr.rs
index bac316c..5014f74 100644
--- a/src/cexpr.rs
+++ b/src/cexpr.rs
@@ -26,7 +26,7 @@ impl CNumber {
match self {
CNumber::Integer(v) => Ok(SExpr::SInteger(*v)),
CNumber::Rational(a, b) => Ok(SExpr::SList(vec![
- SExpr::SBuiltin("/".to_string()),
+ SExpr::SIdentifier("/".to_string()),
SExpr::SInteger(*a),
SExpr::SInteger(*b as i64),
])),
@@ -56,13 +56,11 @@ impl CExpr {
// not all cases are handled; some atoms are covered trivialy
match sexpr {
SExpr::SNull => Err("null not handled".to_string()),
- SExpr::STrue | SExpr::SFalse => Err("booleans not handled".to_string()),
+ SExpr::SBoolean(_) => Err("booleans not handled".to_string()),
SExpr::SInteger(v) => Ok(CExpr::Number(CNumber::Integer(*v))),
SExpr::SFloat(v) => Err("floats not handled".to_string()),
- SExpr::SBuiltin(v) => Ok(CExpr::Symbol(v.to_string())),
- SExpr::SSymbol(v) => Err(format!("symbols (quoted identifiers) not handled: {}", v)),
- SExpr::SIdentifier(v) => Ok(CExpr::Symbol(v.to_string())),
SExpr::SString(_) => Err("null not handled".to_string()),
+ SExpr::SIdentifier(v) => Ok(CExpr::Symbol(v.to_string())),
SExpr::SList(_) => Err("null not handled".to_string()),
//SExpr::SList(l) => CExpr::from_sexpr_list(l),
}
@@ -74,16 +72,16 @@ impl CExpr {
unimplemented!()
}
match list[0] {
- SExpr::SBuiltin("+") => {
+ SExpr::SIdentifier("+") => {
Ok(CExpr::Sum(
// XXX
None,
list[1..].iter().map(|v| CExpr::from_sexpr(v)).collect::<Result<Vec<SExpr>, String>>()?,
))
},
- SExpr::SBuiltin("*") => {
+ SExpr::SIdentifier("*") => {
},
- SExpr::SBuiltin("^") => {
+ SExpr::SIdentifier("^") => {
},
_ => {
unimplemented!()
@@ -105,17 +103,17 @@ impl CExpr {
CExpr::Symbol(s) => Ok(SExpr::SIdentifier(s.to_string())),
CExpr::Number(n) => n.to_sexpr(),
CExpr::Sum(n, l) => Ok(SExpr::SList(vec![
- SExpr::SBuiltin("+".to_string()),
+ SExpr::SIdentifier("+".to_string()),
SExpr::SList(l.iter().map(|v| v.to_sexpr()).collect::<Result<Vec<SExpr>, String>>()?),
// XXX: n
])),
CExpr::Product(n, l) => Ok(SExpr::SList(vec![
- SExpr::SBuiltin("*".to_string()),
+ SExpr::SIdentifier("*".to_string()),
SExpr::SList(l.iter().map(|v| v.to_sexpr()).collect::<Result<Vec<SExpr>, String>>()?),
// XXX: n
])),
CExpr::Power(a, b) => Ok(SExpr::SList(vec![
- SExpr::SBuiltin("^".to_string()),
+ SExpr::SIdentifier("^".to_string()),
a.to_sexpr()?,
b.to_sexpr()?,
])),