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/type/mod.rs | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/type/mod.rs (limited to 'src/type/mod.rs') 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