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§
- Argument
Match - Matching of
ParameterListwithArgumentValueListinto Tuple - Argument
Value List Raw - Alternative evaluation type.
- Capture
- Output buffer to catch what
__builtin::printis printing. - Eval
Context - Context for evaluation of a resolved µcad file.
- Stdout
- Output what
__builtin::printis printing to stdout.
Enums§
- Attribute
Error - Error type for attributes.
- Eval
Error - Evaluation error.
- Match
Error - An error that occurred when looking for matching arguments between a call and a parameter definition.
Traits§
- Call
Method - Trait for calling methods of values
- Call
Trait - 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§
- Eval
Result - Result type of any evaluation.