diff --git a/src/semantic/checks/expression.rs b/src/semantic/checks/expression.rs index 0ea1e2c..87b9f69 100644 --- a/src/semantic/checks/expression.rs +++ b/src/semantic/checks/expression.rs @@ -350,19 +350,30 @@ impl SemanticCheck for Expression<'_> { #[cfg(test)] mod tests { use crate::{ - lexic::token::Token, + lexic::{self, get_tokens, token::Token}, semantic::{impls::SemanticCheck, std::populate, symbol_table::SymbolTable}, - syntax::ast::{ - functions::{ArgumentsList, FunctionCall}, - Expression, + syntax::{ + ast::{ + functions::{ArgumentsList, FunctionCall}, + Expression, + }, + parseable::Parseable, }, }; + fn t(i: &str) -> Vec { + get_tokens(&i.into()).unwrap() + } + fn exp<'a>(t: &'a Vec) -> Expression<'a> { + Expression::try_parse(t, 0).unwrap().0 + } + #[test] fn should_error_on_undefined_symbol() { // source code: `print()` - let expr_token = Token::new_identifier("print".into(), 0); - let expr_function = Expression::Identifier(&expr_token); + let b = t("print()"); + let expr_function = exp(&b); + let arguments = ArgumentsList { arguments: vec![], paren_open_pos: 5, diff --git a/src/semantic/impls.rs b/src/semantic/impls.rs index 0a5cf41..72b0d69 100644 --- a/src/semantic/impls.rs +++ b/src/semantic/impls.rs @@ -4,6 +4,10 @@ use super::symbol_table::SymbolTable; /// Allows this type to have it's semantics checked. pub trait SemanticCheck { + /// Checks the semantics of this AST node and performs typechecking + /// + /// Types are provided by the Typed trait, because not every AST node + /// will have a defined type fn check_semantics(&self, scope: &SymbolTable) -> Result<(), MistiError>; } diff --git a/src/syntax/mod.rs b/src/syntax/mod.rs index e905f3b..caab368 100755 --- a/src/syntax/mod.rs +++ b/src/syntax/mod.rs @@ -1,7 +1,7 @@ use crate::error_handling::MistiError; mod functions; -mod parseable; +pub mod parseable; mod parsers; mod utils;