Typechecking infrastructure

This commit is contained in:
greg 2018-11-06 13:44:52 -08:00
parent 836bed1207
commit 15f9dbe7a6
2 changed files with 21 additions and 2 deletions

View File

@ -43,6 +43,7 @@ mod eval;
pub struct Schala { pub struct Schala {
state: eval::State<'static>, state: eval::State<'static>,
symbol_table: Rc<RefCell<symbol_table::SymbolTable>>, symbol_table: Rc<RefCell<symbol_table::SymbolTable>>,
type_context: typechecking::TypeContext,
active_parser: Option<parsing::Parser>, active_parser: Option<parsing::Parser>,
} }
@ -62,6 +63,7 @@ impl Schala {
Schala { Schala {
symbol_table: symbols.clone(), symbol_table: symbols.clone(),
state: eval::State::new(symbols), state: eval::State::new(symbols),
type_context: typechecking::TypeContext::new(),
active_parser: None, active_parser: None,
} }
} }
@ -126,8 +128,9 @@ fn symbol_table(handle: &mut Schala, input: ast::AST, comp: Option<&mut Unfinish
} }
} }
fn typechecking(_handle: &mut Schala, input: ast::AST, _comp: Option<&mut UnfinishedComputation>) -> Result<ast::AST, String> { fn typechecking(handle: &mut Schala, input: ast::AST, _comp: Option<&mut UnfinishedComputation>) -> Result<ast::AST, String> {
Ok(input)
handle.type_context.typecheck(&input).map(|_| input)
} }
fn ast_reducing(handle: &mut Schala, input: ast::AST, comp: Option<&mut UnfinishedComputation>) -> Result<reduced_ast::ReducedAST, String> { fn ast_reducing(handle: &mut Schala, input: ast::AST, comp: Option<&mut UnfinishedComputation>) -> Result<reduced_ast::ReducedAST, String> {

View File

@ -1,3 +1,19 @@
use std::rc::Rc; use std::rc::Rc;
use ast::AST;
pub type TypeName = Rc<String>; pub type TypeName = Rc<String>;
pub struct TypeContext {
}
impl TypeContext {
pub fn new() -> TypeContext {
TypeContext { }
}
pub fn typecheck(&mut self, _ast: &AST) -> Result<(), String> {
Ok(())
}
}