skele of eval function
This commit is contained in:
parent
3434a49cc1
commit
306ec6af09
1 changed files with 41 additions and 6 deletions
47
src/eval.rs
47
src/eval.rs
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use crate::segment::{Ast};
|
use crate::segment::{Ast, Ctr};
|
||||||
use crate::func::FTable;
|
use crate::func::FTable;
|
||||||
use crate::vars::VTable;
|
use crate::vars::VTable;
|
||||||
|
|
||||||
|
|
@ -26,10 +26,45 @@ use crate::vars::VTable;
|
||||||
* representing the simplest possible form of the input
|
* representing the simplest possible form of the input
|
||||||
*/
|
*/
|
||||||
pub fn eval(
|
pub fn eval(
|
||||||
_ast: Ast,
|
ast: Ast,
|
||||||
_vars: Rc<RefCell<VTable>>,
|
vars: Rc<RefCell<VTable>>,
|
||||||
_funcs: Rc<RefCell<FTable>>,
|
funcs: Rc<RefCell<FTable>>,
|
||||||
_sym_loose: bool
|
sym_loose: bool
|
||||||
) -> Result<Ast, String> {
|
) -> Result<Ast, String> {
|
||||||
Err("Unimplemented".to_string())
|
eval_inner(ast, vars, funcs, sym_loose, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn eval_inner(
|
||||||
|
ast: Ast,
|
||||||
|
vars: Rc<RefCell<VTable>>,
|
||||||
|
funcs: Rc<RefCell<FTable>>,
|
||||||
|
sym_loose: bool,
|
||||||
|
first_item: bool
|
||||||
|
) -> Result<Ast, String> {
|
||||||
|
/* TODO:
|
||||||
|
* 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
|
||||||
|
* 4. else call process_ctr on cdr
|
||||||
|
* (and set new.cdr to result)
|
||||||
|
* 5. return new ast
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
fn process_ctr(
|
||||||
|
ctr: Ctr,
|
||||||
|
vars: Rc<RefCell<VTable>>,
|
||||||
|
funcs: Rc<RefCell<FTable>>,
|
||||||
|
sym_loose: bool,
|
||||||
|
first_item: bool
|
||||||
|
) -> Result<Ctr, String> {
|
||||||
|
/* TODO:
|
||||||
|
* 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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue