aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib.rs1
-rw-r--r--src/type/mod.rs34
2 files changed, 35 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1eabc19..ee6c22e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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!()
+ }
+}