Module eval

Module eval 

Source
Expand description

Evaluation of parsed content.

To be able to evaluate (run) a source file, it must be loaded, parsed and resolved. To do so a EvalContext can be created with EvalContext::new() based on an already resolved symbol or by using EvalContext::from_source() or ContextBuilder::from_source_captured() which both automatically load and resolve the source file and build a context around it which then can be evaluated with EvalContext::eval():

use microcad_lang::eval::EvalContext;
use microcad_lang::diag::Diag;
use std::io::stdout;

// create a context for evaluation of the source file
let mut context = EvalContext::from_source(
    "my.µcad",              // root file name
    builtin_module(),    // `__builtin` library
    &["./std/lib".into()]       // list of std library path
).expect("successful load, parse and resolve");

// evaluate the source file in it's context
let node = context.eval().expect("successful evaluation");

// print any error
println!("{}", context.diagnosis());

Macros§

eval_todo
Like todo!() but within a evaluation context

Structs§

ArgumentMatch
Matching of ParameterList with ArgumentValueList into Tuple
ArgumentValueListRaw
Alternative evaluation type.
Capture
Output buffer to catch what __builtin::print is printing.
EvalContext
Context for evaluation of a resolved µcad file.
Stdout
Output what __builtin::print is printing to stdout.

Enums§

AttributeError
Error type for attributes.
EvalError
Evaluation error.
MatchError
An error that occurred when looking for matching arguments between a call and a parameter definition.

Traits§

CallMethod
Trait for calling methods of values
CallTrait
Trait for calls with argument list.
Eval
Evaluation trait.
Output
Trait which Context is using to access or redirect the µcad code’s console output.

Type Aliases§

EvalResult
Result type of any evaluation.