Added modules

This commit is contained in:
Erin 2022-07-21 18:02:30 +02:00 committed by ondra05
parent 5ad89874fb
commit ee6c092577

View file

@ -12,6 +12,7 @@ pub enum Value<'a> {
List(Box<List<'a>>),
Vector(Vec<Self>),
Map(BTreeMap<Self, Self>),
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<u64, Value<'a>>,
symbol_table: BTreeMap<String, u64>,
}
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"),