use ::ast::{self, WithLocation}; use super::environment; use super::types::Ty; #[derive(Debug)] pub enum TypeError { Unimplemented, } type TypeEnvironment<'a> = environment::Environment<'a, String, Ty>; pub type Result = ::std::result::Result>; pub fn translate(program: &ast::Program) -> Result { trans_exp(TypeEnvironment::new(None), &*program.0) } fn trans_exp<'a>(venv: TypeEnvironment<'a>, exp: &WithLocation) -> Result { use ast::Expression::*; match &exp.value { &Let(ref decls, ref body) => { Err(WithLocation::new(TypeError::Unimplemented, exp.start, exp.end)) }, &UnaryOp(ref op, ref operand) => { Err(WithLocation::new(TypeError::Unimplemented, exp.start, exp.end)) }, &BinOp(ref op, ref left, ref right) => { Err(WithLocation::new(TypeError::Unimplemented, exp.start, exp.end)) }, &Number(_) => Ok(Ty::Int), &String(_) => Ok(Ty::String), &Name(ref name) => { Err(WithLocation::new(TypeError::Unimplemented, exp.start, exp.end)) }, &Nil => { Err(WithLocation::new(TypeError::Unimplemented, exp.start, exp.end)) }, } }