diff options
author | bnewbold <bnewbold@robocracy.org> | 2016-12-25 22:16:46 -0800 |
---|---|---|
committer | bnewbold <bnewbold@robocracy.org> | 2016-12-25 22:17:22 -0800 |
commit | 14d055dcc41044061357f206fe4ed71ce61fffce (patch) | |
tree | 40ba0c183d938e8ef9309e710f003f298350d27f /src/transpile_scheme.rs | |
parent | 68aa8cb130ff68395c416b36a1e5661e6fa18e5d (diff) | |
download | modelthing-14d055dcc41044061357f206fe4ed71ce61fffce.tar.gz modelthing-14d055dcc41044061357f206fe4ed71ce61fffce.zip |
rustfmt
Diffstat (limited to 'src/transpile_scheme.rs')
-rw-r--r-- | src/transpile_scheme.rs | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/transpile_scheme.rs b/src/transpile_scheme.rs index 79492d8..7c25047 100644 --- a/src/transpile_scheme.rs +++ b/src/transpile_scheme.rs @@ -13,30 +13,28 @@ impl TranspileScheme for ModelicaModel { let mut constants = vec![]; for (c, e) in self.get_constant_vars() { if let Some(v) = e { - constants.push(format!("({} {})", - c, try!(v.repr_scheme()))); + constants.push(format!("({} {})", c, try!(v.repr_scheme()))); } } let mut binds = vec![]; let mut outputs = vec![]; for eq in self.equations.iter() { if let Expr::Ident(ref symb) = eq.lhs { - binds.push(format!("({} {})", - symb, - try!(eq.rhs.repr_scheme()))); + binds.push(format!("({} {})", symb, try!(eq.rhs.repr_scheme()))); outputs.push(symb.to_string()); } else { - return Err("Expected an identifier on LHS (in this partial implementation)".to_string()) + return Err("Expected an identifier on LHS (in this partial implementation)" + .to_string()); } } Ok(format!(r#"(lambda ({args}) (let ({constants}) (letrec ({binds}) (list {outputs}))))"#, - args = self.get_free_vars().join(" "), - constants = constants.join("\n "), - binds = binds.join("\n "), - outputs = outputs.join(" "))) + args = self.get_free_vars().join(" "), + constants = constants.join("\n "), + binds = binds.join("\n "), + outputs = outputs.join(" "))) } } @@ -53,11 +51,12 @@ impl TranspileScheme for Expr { Der(ref e) => Ok(format!("(der {})", try!(e.repr_scheme()))), Sign(ref e) => Ok(format!("(sign {})", try!(e.repr_scheme()))), MathUnaryExpr(func, ref e) => Ok(format!("({:?} {})", func, try!(e.repr_scheme()))), - BinExpr(op, ref l, ref r) => + BinExpr(op, ref l, ref r) => { Ok(format!("({:?} {} {})", - op, - try!(l.repr_scheme()), - try!(r.repr_scheme()))), + op, + try!(l.repr_scheme()), + try!(r.repr_scheme()))) + } Array(_) => Err("Array unimplemented".to_string()), } } |