all tests green

Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-02-25 23:36:30 -08:00
parent 82854a58f8
commit 93a1e06a53
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
5 changed files with 94 additions and 32 deletions

View file

@ -88,6 +88,7 @@ impl SymTable {
Some(s) => s,
None => return Err(format!("undefined symbol: {}", name)),
};
self.insert(name.to_string(), symbol.clone());
let cond_args: &Seg;
let outer_scope_seg_holder: Seg;
@ -100,10 +101,15 @@ impl SymTable {
cond_args = &outer_scope_seg_holder;
}
let res = symbol.call(cond_args, self);
self.insert(name.to_string(), symbol);
symbol.call(cond_args, self)
}
res
pub fn is_function_type(&self, name: &String) -> Option<bool> {
if let ValueType::VarForm(_) = self.get(name)?.value {
Some(false)
} else {
Some(true)
}
}
}
@ -144,6 +150,11 @@ impl Args {
"expected {} args. Got {}.",
num, called_arg_count
));
} else if let Ctr::None = *args.car {
return Err(format!(
"expected {} args. Got 0.",
num,
));
}
}
@ -202,7 +213,7 @@ impl Symbol {
let evaluated_args: &Seg;
let outer_scope_seg_storage: Seg;
let outer_scope_eval: Box<Ctr>;
if self.conditional_branches {
if !self.conditional_branches {
let outer_scope_eval_result = eval(args, syms);
// dont listen to clippy. using ? will move the value.
if let Err(s) = outer_scope_eval_result {
@ -257,7 +268,17 @@ impl Symbol {
Err(e) => return Err(e),
}
} else {
panic!("function body not in standard form!")
let temp = Seg::from_mono(iterate.car.clone());
match eval(&temp, syms) {
Ok(ctr) => {
if let Ctr::Seg(s) = *ctr {
result = s.car.clone();
} else {
result = ctr;
}
},
Err(e) => return Err(e),
}
}
match *iterate.cdr {