aboutsummaryrefslogtreecommitdiff
path: root/src/type
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-01 23:06:26 +0300
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-08-01 23:06:26 +0300
commit0f9542109275de75641185d4d94dbe7c35a49088 (patch)
treeb0b421ed5d0e2ff29c8f71c7161aae3d46c1fa04 /src/type
parent992865e827cdfffa6451ca37e74f185c5228f894 (diff)
downloadmyslip-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/type')
-rw-r--r--src/type/mod.rs34
1 files changed, 34 insertions, 0 deletions
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!()
+ }
+}