Get dataypes from sybols
This commit is contained in:
parent
cfbb86ab68
commit
3a11000fe0
@ -11,6 +11,11 @@
|
|||||||
- [ ] Stdlib
|
- [ ] Stdlib
|
||||||
- [ ] Document code
|
- [ ] 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
|
## v0.0.1
|
||||||
|
|
||||||
- Compilation of a `val` binding with a number.
|
- Compilation of a `val` binding with a number.
|
||||||
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -169,7 +169,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "misti"
|
name = "misti"
|
||||||
version = "0.0.1"
|
version = "0.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "misti"
|
name = "misti"
|
||||||
version = "0.0.1"
|
version = "0.0.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
@ -1,25 +1,20 @@
|
|||||||
use crate::ast_types::Expression;
|
use super::symbol_table::{SymbolTable, _NUMBER, _STRING, _BOOLEAN};
|
||||||
use crate::symbol_table::{_STRING, _BOOLEAN};
|
use super::ast_types::{ModuleAST, Binding, Expression};
|
||||||
|
|
||||||
use super::symbol_table::{SymbolTable, _NUMBER};
|
|
||||||
use super::ast_types::{ModuleAST, Binding};
|
|
||||||
|
|
||||||
/// Checks the AST. In the future should return a list of errors.
|
/// 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) {
|
pub fn check_ast<'a>(ast: &'a mut ModuleAST, symbol_table: &'a mut SymbolTable) {
|
||||||
for binding in &ast.bindings {
|
for binding in &ast.bindings {
|
||||||
match binding {
|
match binding {
|
||||||
Binding::Val(val_binding) => {
|
Binding::Val(binding) => {
|
||||||
// TODO: create a function to get the datatype, instead of a hardcoded value
|
|
||||||
symbol_table.add(
|
symbol_table.add(
|
||||||
val_binding.identifier,
|
binding.identifier,
|
||||||
get_expression_type(&val_binding.expression).as_str()
|
get_expression_type(&binding.expression).as_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Binding::Var(var_binding) => {
|
Binding::Var(binding) => {
|
||||||
// TODO: create a function to get the datatype, instead of a hardcoded value
|
|
||||||
symbol_table.add(
|
symbol_table.add(
|
||||||
var_binding.identifier,
|
binding.identifier,
|
||||||
get_expression_type(&var_binding.expression).as_str(),
|
get_expression_type(&binding.expression).as_str(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user