pub fn evaluate(
    stmt_list: StmtList,
    ctxt: &ProgramContext,
) -> Result<EvaluationResult, Box<dyn Error>> {
    let eval_rules = build_rules(ctxt)?;
    let simplify = |expr: RcExpr| evaluate_expr(expr, &eval_rules, &ctxt);
    let evaluated = stmt_list
        .into_iter()
        .map(|stmt| stmt.update_with(simplify, |asgn| asgn.redefine_with(simplify)))
        .collect::<Vec<_>>();

    let simplified = StmtList::new(evaluated);
    let diagnostics = validate(&simplified, "", ctxt, &eval_rules); // TODO: propogate program text
    Ok(EvaluationResult {
        simplified,
        diagnostics,
    })
}
/// Evaluates a list of statements to as simplified a form as possible for each.
/// The evaluation may be partial, as some values (like variables) may be unknown.
Evaluates a list of statements to as simplified a form as possible for each.
The evaluation may be partial, as some values (like variables) may be unknown.
Evaluates a list of statements to as simplified a form as possible for each . The evaluation may be partial as some values ( like variables ) may be unknown .
pub fn evaluate(
    stmt_list: StmtList,
    ctxt: &ProgramContext,
) -> Result<EvaluationResult, Box<dyn Error>> {
    let eval_rules = build_rules(ctxt)?;
    let simplify = |expr: RcExpr| evaluate_expr(expr, &eval_rules, &ctxt);
    let evaluated = stmt_list
        .into_iter()
        .map(|stmt| stmt.update_with(simplify, |asgn| asgn.redefine_with(simplify)))
        .collect::<Vec<_>>();
    let simplified = StmtList::new(evaluated);
    let diagnostics = validate(&simplified, "", ctxt, &eval_rules); // TODO: propogate program text
    Ok(EvaluationResult {
        simplified,
        diagnostics,
    })
}
pub fn evaluate ( stmt_list : StmtList , ctxt : & ProgramContext , ) -> Result < EvaluationResult , Box < dyn Error > > { let eval_rules = build_rules ( ctxt ) ? ; let simplify = | expr : RcExpr | evaluate_expr ( expr , & eval_rules , & ctxt ) ; let evaluated = stmt_list . into_iter ( ) . map ( | stmt | stmt . update_with ( simplify , | asgn | asgn . redefine_with ( simplify ) ) ) . collect :: < Vec < _ > > ( ) ; let simplified = StmtList :: new ( evaluated ) ; let diagnostics = validate ( & simplified , " " , ctxt , & eval_rules ) ; // TODO: propogate program text Ok ( EvaluationResult { simplified , diagnostics , } ) }
Evaluates a list of statements to as simplified a form as possible for each.
Evaluates a list of statements to as simplified a form as possible for each .
stmt_list
StmtList
ctxt
&ProgramContext
stmt_list
StmtList
ctxt
&ProgramContext