From ee6c0925772dc5c8155d5a4a0f65bae0f935de83 Mon Sep 17 00:00:00 2001 From: Erin Date: Thu, 21 Jul 2022 18:02:30 +0200 Subject: [PATCH] Added modules --- src/value.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/value.rs b/src/value.rs index e280472..66c6572 100644 --- a/src/value.rs +++ b/src/value.rs @@ -12,6 +12,7 @@ pub enum Value<'a> { List(Box>), Vector(Vec), Map(BTreeMap), + Module(Module<'a>), Symbol(Symbol<'a>), Keyword(Cow<'a, str>), Function { @@ -44,6 +45,12 @@ impl<'a> Display for Symbol<'a> { } } +#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] +pub struct Module<'a> { + members: BTreeMap>, + symbol_table: BTreeMap, +} + impl<'a> Display for Value<'a> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -55,6 +62,7 @@ impl<'a> Display for Value<'a> { "[", "]", ), + Value::Module(_) => write!(f, "#module#"), Value::Symbol(sym) => write!(f, "{sym}"), Value::Keyword(kw) => write!(f, ":{kw}"), Value::Function { .. } => write!(f, "fn"),