diff --git a/CHANGELOG.md b/CHANGELOG.md index df9e208..70b2a5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ - [ ] Stdlib - [ ] Document code +## v0.0.2 + +- Compilation of `val` and `var` bindings with a number, string or boolean as value. +- Register symbols and datatypes in the Symbol table. + ## v0.0.1 - Compilation of a `val` binding with a number. diff --git a/Cargo.lock b/Cargo.lock index 66583c3..c3d9de2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -169,7 +169,7 @@ dependencies = [ [[package]] name = "misti" -version = "0.0.1" +version = "0.0.2" dependencies = [ "chrono", ] diff --git a/Cargo.toml b/Cargo.toml index 35d2d65..e904f1a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "misti" -version = "0.0.1" +version = "0.0.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/semantic/mod.rs b/src/semantic/mod.rs index 055283d..7557eca 100644 --- a/src/semantic/mod.rs +++ b/src/semantic/mod.rs @@ -1,25 +1,20 @@ -use crate::ast_types::Expression; -use crate::symbol_table::{_STRING, _BOOLEAN}; - -use super::symbol_table::{SymbolTable, _NUMBER}; -use super::ast_types::{ModuleAST, Binding}; +use super::symbol_table::{SymbolTable, _NUMBER, _STRING, _BOOLEAN}; +use super::ast_types::{ModuleAST, Binding, Expression}; /// Checks the AST. In the future should return a list of errors. pub fn check_ast<'a>(ast: &'a mut ModuleAST, symbol_table: &'a mut SymbolTable) { for binding in &ast.bindings { match binding { - Binding::Val(val_binding) => { - // TODO: create a function to get the datatype, instead of a hardcoded value + Binding::Val(binding) => { symbol_table.add( - val_binding.identifier, - get_expression_type(&val_binding.expression).as_str() + binding.identifier, + get_expression_type(&binding.expression).as_str() ); } - Binding::Var(var_binding) => { - // TODO: create a function to get the datatype, instead of a hardcoded value + Binding::Var(binding) => { symbol_table.add( - var_binding.identifier, - get_expression_type(&var_binding.expression).as_str(), + binding.identifier, + get_expression_type(&binding.expression).as_str(), ); } }