Evaluator

Struct Evaluator 

Source
pub struct Evaluator { /* private fields */ }
Expand description

Scheme evaluator

Corresponds to OpenJade’s Interpreter class.

§Usage

let mut evaluator = Evaluator::new();
let result = evaluator.eval(expr, env)?;

Implementations§

Source§

impl Evaluator

Source

pub fn new() -> Self

Create a new evaluator without a grove

Source

pub fn with_grove(grove: Rc<dyn Grove>) -> Self

Create a new evaluator with a grove

Source

pub fn set_source_file(&mut self, file: String)

Set the current source file (for error reporting)

Source

pub fn source_file(&self) -> Option<&str>

Get the current source file

Source

pub fn set_position(&mut self, position: Position)

Set the current position (for error reporting)

Source

pub fn set_backend(&mut self, backend: Rc<RefCell<dyn FotBuilder>>)

Set the backend

Source

pub fn set_grove(&mut self, grove: Rc<dyn Grove>)

Set the grove

Source

pub fn grove(&self) -> Option<&Rc<dyn Grove>>

Get the grove

Source

pub fn set_current_node(&mut self, node: Box<dyn Node>)

Set the current node

Source

pub fn current_node(&self) -> Option<Rc<Box<dyn Node>>>

Get the current node

Source

pub fn clear_current_node(&mut self)

Clear the current node

Source

pub fn process_root(&mut self, env: Gc<Environment>) -> EvalResult

Start DSSSL processing from the root node

Corresponds to OpenJade’s ProcessContext::process(). After template loading, this triggers automatic tree processing.

Source

pub fn process_node(&mut self, env: Gc<Environment>) -> EvalResult

Process the current node

Corresponds to OpenJade’s ProcessContext::processNode().

§Algorithm (from OpenJade):
  1. If character data node, output directly
  2. If element node: a. Find matching construction rule by GI b. If rule found, evaluate it (returns sosofo) c. If no rule, default behavior: process-children
Source

pub fn eval(&mut self, expr: Value, env: Gc<Environment>) -> EvalResult

Evaluate an expression in an environment

Corresponds to OpenJade’s Interpreter::eval().

§Evaluation Rules
  1. Self-evaluating: Numbers, strings, bools, chars → return as-is
  2. Symbols: Variable lookup in environment
  3. Lists: Check first element for special forms, otherwise apply

Trait Implementations§

Source§

impl Default for Evaluator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.