From 06798d622327707ca3f3b42d65fc3d1a25ae3c57 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sun, 10 Aug 2025 18:38:49 +0300 Subject: Added term level type literals (for function type signatures) --- src/sexp/mod.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/sexp/mod.rs') diff --git a/src/sexp/mod.rs b/src/sexp/mod.rs index 296553f..11c185f 100644 --- a/src/sexp/mod.rs +++ b/src/sexp/mod.rs @@ -4,6 +4,8 @@ pub mod util; pub mod subst; pub mod display; +use crate::r#type::Type; + /// A leaf node for S-Expressions. /// /// May represent built-in operators, @@ -33,6 +35,9 @@ pub enum SLeaf { Let, + Ty(Type), + Arr, + Print, Int(i32), @@ -58,6 +63,7 @@ pub enum SExp { use SExp::*; use SLeaf::*; +use crate::sexp::util::*; impl SExp { @@ -71,7 +77,7 @@ impl SExp { SCons(a, b) => SCons(a.clone(), b.clone()).check_let().is_some() || ( - (**a == Atom(Quote) || **a == Atom(Vector)) + (**a == Atom(Quote) || **a == Atom(Vector) || (**a).is_type_lit()) && b.consists_of_values() ), Atom(Var(_)) => false, @@ -85,4 +91,15 @@ impl SExp { _ => false } } + + pub fn is_type_lit(&self) -> bool { + match self { + Atom(Ty(_)) => true, + SCons(a, b) => scons(a.clone(), b.clone()) + .parts() + .into_iter() + .all(|x| x.is_type_lit()), + _ => false + } + } } -- cgit v1.2.3