AST-walking infrastructure

This commit is contained in:
greg 2019-02-10 04:42:30 -08:00
parent e8f1f51639
commit 7d3ae36058

View File

@ -142,6 +142,24 @@ impl<'a> TypeContext<'a> {
} }
pub fn typecheck(&mut self, ast: &AST) -> Result<String, String> { pub fn typecheck(&mut self, ast: &AST) -> Result<String, String> {
Ok(format!("UNIT")) for statement in ast.0.iter() {
self.typecheck_statement(statement.node()).map_err(|err| { err.msg })?
}
Ok("unknown type".to_string())
}
fn typecheck_statement(&mut self, statement: &Statement) -> InferResult<()> {
match statement {
Statement::ExpressionStatement(e) => self.typecheck_expr(e.node()),
Statement::Declaration(decl) => self.typecheck_decl(decl),
}
}
fn typecheck_decl(&mut self, decl: &Declaration) -> InferResult<()> {
Ok(())
}
fn typecheck_expr(&mut self, expr: &Expression) -> InferResult<()> {
Ok(())
} }
} }