all tests green
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
82854a58f8
commit
93a1e06a53
5 changed files with 94 additions and 32 deletions
31
src/sym.rs
31
src/sym.rs
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue