diff --git a/TODO.md b/TODO.md index 75cf39e..518f59c 100644 --- a/TODO.md +++ b/TODO.md @@ -1,5 +1,8 @@ # TODO items +## General code cleanup +- standardize on an error type that isn't String + ## Reduction - make a good type for actual language builtins to avoid string comparisons diff --git a/schala-lang/language/src/ast.rs b/schala-lang/language/src/ast.rs index ae4a6a9..875e155 100644 --- a/schala-lang/language/src/ast.rs +++ b/schala-lang/language/src/ast.rs @@ -27,6 +27,10 @@ impl Meta { pub fn node(&self) -> &T { &self.n } + + pub fn mut_node(&mut self) -> &mut T { + &mut self.n + } } //TODO this PartialEq is here to make tests work - find a way to make it not necessary @@ -46,7 +50,7 @@ pub struct AST(pub Vec>); #[derive(Debug, PartialEq, Clone)] pub enum Statement { ExpressionStatement(Meta), - Declaration(Declaration), + Declaration(Declaration), //TODO Declaration should also be Meta-wrapped; only Expression and Declaration are Meta-wrapped maybe? } pub type Block = Vec>; diff --git a/schala-lang/language/src/scope_resolution.rs b/schala-lang/language/src/scope_resolution.rs index df0ed49..8eee33a 100644 --- a/schala-lang/language/src/scope_resolution.rs +++ b/schala-lang/language/src/scope_resolution.rs @@ -2,5 +2,19 @@ use crate::ast::*; pub fn resolve_scopes(ast: &mut AST) -> Result<(), String> { println!("Resolving scopes - nothing so far!"); + for statement in ast.0.iter_mut() { + match statement.mut_node() { + Statement::Declaration(ref mut decl) => resolve_decl(decl), + Statement::ExpressionStatement(ref mut expr) => resolve_expr(expr), + }?; + } + Ok(()) +} + +fn resolve_decl(decl: &mut Declaration) -> Result<(), String> { + Ok(()) +} + +fn resolve_expr(expr: &mut Meta) -> Result<(), String> { Ok(()) }