diff --git a/src/eval.rs b/src/eval.rs index 0b77991..f5401f3 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -3,6 +3,8 @@ extern crate take_mut; use std::collections::HashMap; use parser::{AST, ASTNode, Expression, Function}; +type Reduction = (T, Option); + #[derive(Debug)] enum SideEffect { Print(String), @@ -136,7 +138,7 @@ impl Evaluator { } } - fn reduce_astnode(&mut self, node: ASTNode) -> (ASTNode, Option) { + fn reduce_astnode(&mut self, node: ASTNode) -> Reduction { use parser::ASTNode::*; match node { ExprNode(expr) => { @@ -155,7 +157,7 @@ impl Evaluator { } } - fn reduce_expr(&mut self, expression: Expression) -> (Expression, Option) { + fn reduce_expr(&mut self, expression: Expression) -> Reduction { use parser::Expression::*; match expression { Null => (Null, None), @@ -262,7 +264,7 @@ impl Evaluator { fn reduce_call(&mut self, name: String, arguments: Vec) - -> (Expression, Option) { + -> Reduction { use parser::Expression::*; // ugly hack for now