From 0f9542109275de75641185d4d94dbe7c35a49088 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Fri, 1 Aug 2025 23:06:26 +0300 Subject: Added boilerplate for Type, TypeError and type_check (small commit, had to sync between desktop and laptop) --- src/lib.rs | 1 + src/type/mod.rs | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/type/mod.rs 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, Box), +} + +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 { + todo!() + } +} -- cgit v1.2.3