Run rustfmt on eval.rs, parser.rs

This commit is contained in:
greg 2017-01-02 22:15:14 -08:00
parent 1858d26638
commit 6794d22f1d
2 changed files with 8 additions and 18 deletions

View File

@ -31,9 +31,7 @@ pub struct Evaluator {
impl Evaluator { impl Evaluator {
pub fn new() -> Evaluator { pub fn new() -> Evaluator {
Evaluator { Evaluator { frames: vec![EnvFrame::new()] }
frames: vec!(EnvFrame::new()),
}
} }
pub fn run(&mut self, ast: AST) -> Vec<String> { pub fn run(&mut self, ast: AST) -> Vec<String> {
@ -159,7 +157,7 @@ impl Evaluator {
} }
FuncDefNode(func) => { FuncDefNode(func) => {
let fn_name = func.prototype.name.clone(); let fn_name = func.prototype.name.clone();
//TODO get rid of this clone // TODO get rid of this clone
self.add_function(fn_name, func.clone()); self.add_function(fn_name, func.clone());
(ExprNode(Expression::Lambda(func)), None) (ExprNode(Expression::Lambda(func)), None)
} }
@ -192,7 +190,7 @@ impl Evaluator {
let binding = SideEffect::AddBinding(var, right); let binding = SideEffect::AddBinding(var, right);
return (Null, Some(binding)); return (Null, Some(binding));
} }
_ => return (Null, None) _ => return (Null, None),
} }
} }
@ -228,7 +226,7 @@ impl Evaluator {
} else { } else {
match else_block { match else_block {
Some(box expr) => (expr, None), Some(box expr) => (expr, None),
None => (Null, None) None => (Null, None),
} }
} }
} }
@ -272,10 +270,7 @@ impl Evaluator {
} }
} }
fn reduce_call(&mut self, fn reduce_call(&mut self, name: String, arguments: Vec<Expression>) -> Reduction<Expression> {
name: String,
arguments: Vec<Expression>)
-> Reduction<Expression> {
use parser::Expression::*; use parser::Expression::*;
// ugly hack for now // ugly hack for now

View File

@ -68,14 +68,9 @@ impl fmt::Display for Expression {
&Null => write!(f, "null"), &Null => write!(f, "null"),
&StringLiteral(ref s) => write!(f, "\"{}\"", s), &StringLiteral(ref s) => write!(f, "\"{}\"", s),
&Number(n) => write!(f, "{}", n), &Number(n) => write!(f, "{}", n),
&Lambda(Function { &Lambda(Function { prototype: Prototype { ref name, ref parameters, .. }, .. }) => {
prototype: Prototype { write!(f, "«function: {}, {} arg(s)»", name, parameters.len())
ref name, }
ref parameters,
..
},
..
}) => write!(f, "«function: {}, {} arg(s)»", name, parameters.len()),
_ => write!(f, "UNIMPLEMENTED"), _ => write!(f, "UNIMPLEMENTED"),
} }
} }