pub struct Evaluator;Expand description
Lowerer from parse syntax to semantic document graph.
§Examples
use mos_eval::Evaluator;
let evaluator = Evaluator::new();
assert_eq!(format!("{evaluator:?}"), "Evaluator");Implementations§
Source§impl Evaluator
impl Evaluator
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Construct an evaluator.
§Examples
use mos_eval::Evaluator;
let evaluator = Evaluator::new();
assert_eq!(format!("{evaluator:?}"), "Evaluator");Sourcepub fn evaluate(tree: &SyntaxTree) -> LowerResult
pub fn evaluate(tree: &SyntaxTree) -> LowerResult
Lower tree into a semantic [Document] and hash its authored nodes.
Bibliography sources are marked unloaded in those hashes; use
lower_tree to include their contents as well.
§Examples
use std::path::Path;
use mos_core::CollectingSink;
use mos_eval::Evaluator;
let mut sink = CollectingSink::new();
let parse_result = mos_parse::parse("= Hello\n", Path::new("main.mos"), &mut sink);
assert!(
parse_result.is_ok(),
"parse structurally aborted: {parse_result:?}"
);
if let Ok(tree) = parse_result {
let result = Evaluator::evaluate(&tree);
assert_eq!(result.document.len(), 3);
}pub(crate) fn evaluate_unhashed(tree: &SyntaxTree) -> LowerResult
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Evaluator
impl RefUnwindSafe for Evaluator
impl Send for Evaluator
impl Sync for Evaluator
impl Unpin for Evaluator
impl UnsafeUnpin for Evaluator
impl UnwindSafe for Evaluator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more