Added modules

main
ondra05 2022-07-21 18:02:30 +02:00
parent 383e93ce08
commit 18ab03945e
1 changed files with 8 additions and 0 deletions

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"),