From 3a97401f614fd0f5701674e0781c4d48b031ce5c Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 7 Oct 2017 21:57:51 -0700 Subject: [PATCH] Add symbol table insertion method skeleton --- src/schala_lang/type_check.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/schala_lang/type_check.rs b/src/schala_lang/type_check.rs index 964d6ee..ad31da4 100644 --- a/src/schala_lang/type_check.rs +++ b/src/schala_lang/type_check.rs @@ -1,11 +1,24 @@ use schala_lang::parsing::{AST, Statement, Declaration, Expression, ExpressionType, Operation, TypeAnno}; +struct SymbolTable { +} + +impl SymbolTable { + fn new() -> SymbolTable { + SymbolTable { } + } + + fn add_symbols(&mut self, ast: &AST) { + } +} + pub struct TypeContext { + symbol_table: SymbolTable, } impl TypeContext { pub fn new() -> TypeContext { - TypeContext { } + TypeContext { symbol_table: SymbolTable::new() } } } @@ -34,6 +47,9 @@ impl TypeCheckResult { impl TypeContext { pub fn type_check(&mut self, ast: &AST) -> TypeCheckResult { use self::ExpressionType::*; + + self.symbol_table.add_symbols(ast); + for statement in ast.0.iter() { match statement { &Statement::Declaration(ref _decl) => {