diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-01 23:06:26 +0300 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-08-01 23:06:26 +0300 |
commit | 0f9542109275de75641185d4d94dbe7c35a49088 (patch) | |
tree | b0b421ed5d0e2ff29c8f71c7161aae3d46c1fa04 /src | |
parent | 992865e827cdfffa6451ca37e74f185c5228f894 (diff) | |
download | myslip-0f9542109275de75641185d4d94dbe7c35a49088.tar.gz myslip-0f9542109275de75641185d4d94dbe7c35a49088.zip |
Added boilerplate for Type, TypeError and type_check
(small commit, had to sync between desktop and laptop)
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 1 | ||||
-rw-r--r-- | src/type/mod.rs | 34 |
2 files changed, 35 insertions, 0 deletions
@@ -1,2 +1,3 @@ pub mod sexp; pub mod parse; +pub mod r#type; diff --git a/src/type/mod.rs b/src/type/mod.rs new file mode 100644 index 0000000..623edc9 --- /dev/null +++ b/src/type/mod.rs @@ -0,0 +1,34 @@ + +use crate::sexp::{SExp, SExp::*}; + +pub enum Type { + Integer, + Arrow(Box<Type>, Box<Type>), +} + +pub enum TypeError { + UndefinedVariable(String), + InvalidOperator { + operator: SExp, + expected: Type, + found: Type, + }, + InvalidArgList { + arglist: SExp, + expected: Type, + found: Type, + }, + OtherError +} + +impl SExp { + /// ```rust + /// use melisp::{ + /// r#type::{*, Type::*, TypeError::*}, + /// sexp::{SExp::*, SLeaf::*, util::*}, + /// }; + /// ``` + pub fn type_check(&self) -> Result<Type, TypeError> { + todo!() + } +} |