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

View File

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