diff options
Diffstat (limited to 'src/sexp/mod.rs')
-rw-r--r-- | src/sexp/mod.rs | 19 |
1 files changed, 18 insertions, 1 deletions
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 + } + } } |