in progress commit

- fill out eval skele
- documentation comments in var tabel
This commit is contained in:
Aidan 2021-03-17 00:03:43 -07:00
parent 306ec6af09
commit f83872d8b5
No known key found for this signature in database
GPG key ID: 327711E983899316
2 changed files with 28 additions and 3 deletions

View file

@ -41,13 +41,13 @@ fn eval_inner(
sym_loose: bool,
first_item: bool
) -> Result<Ast, String> {
/* TODO:
/* LOGIC:
* 1. make new ast
* 2. call process_ctr on ast.car
* 3. set new.car to result
* 3. if cdr is an AST
* - set first_item to false
* - set new.cdr to recur of this
* - set new.cdr to result of process_ctr(ast.ctr)
* 4. else call process_ctr on cdr
* (and set new.cdr to result)
* 5. return new ast
@ -61,10 +61,34 @@ fn process_ctr(
sym_loose: bool,
first_item: bool
) -> Result<Ctr, String> {
/* TODO:
/* LOGIC:
* 1. if symbol, unwrap (DEEP COPY)
* 2. if first_item and symbol, call function?
* (else: return var copy)
* 3. if list return result of eval()
* 4. finally, return a clone (shallow copy) of datum
*/
match ctr {
Symbol(token) => {
let mut tok = token;
if let Some(s) = vt.borrow().get(token) {
if first_item {
if let String(t) = s {
tok = t;
} // else improper var type so ignore
} else {
// TODO: DEEP COPY. return
}
} else if !first_item && !sym_loose {
return Err("variable not found")
}
if first_item && let Some(f) = ft.borrow().get(tok) {
// TODO: call function. set return
}
},
Seg(tree) => eval_inner(tree, vars, funcs, sym_loose, first_item),
_ => Ok(ctr.clone())
}
}