[][src]Struct arithmetic_eval::Interpreter

pub struct Interpreter<'a, T: Grammar> { /* fields omitted */ }

Simple interpreter for arithmetic expressions.

Implementations

impl<'a, T> Interpreter<'a, T> where
    T: Grammar
[src]

pub fn new() -> Self[src]

Creates a new interpreter.

pub fn get_var(&self, name: &'a str) -> Option<&Value<'a, T>>[src]

Gets a variable by name.

pub fn variables(&self) -> impl Iterator<Item = (&'a str, &Value<'a, T>)> + '_[src]

Iterates over variables.

pub fn insert_var(&mut self, name: &'a str, value: Value<'a, T>) -> &mut Self[src]

Inserts a variable with the specified name.

pub fn insert_native_fn(
    &mut self,
    name: &'a str,
    native_fn: impl NativeFn<T> + 'static
) -> &mut Self
[src]

Inserts a native function with the specified name.

impl<'a, T> Interpreter<'a, T> where
    T: Grammar,
    T::Lit: Num + Neg<Output = T::Lit> + Pow<T::Lit, Output = T::Lit>, 
[src]

pub fn evaluate(
    &mut self,
    block: &Block<'a, T>
) -> Result<Value<'a, T>, ErrorWithBacktrace<'a>>
[src]

Evaluates a list of statements.

pub fn compile(
    &self,
    program: &Block<'a, T>
) -> Result<ExecutableModule<'a, T>, SpannedEvalError<'a>>
[src]

Compiles the provided block, returning the compiled module and its imports. The imports can the be changed to run the module with different params.

Trait Implementations

impl<'_, T: Grammar> Clone for Interpreter<'_, T>[src]

impl<'a, T: Debug + Grammar> Debug for Interpreter<'a, T>[src]

impl<'_, T: Grammar> Default for Interpreter<'_, T> where
    T::Lit: Num + Neg<Output = T::Lit> + Pow<T::Lit, Output = T::Lit>, 
[src]

Auto Trait Implementations

impl<'a, T> !RefUnwindSafe for Interpreter<'a, T>

impl<'a, T> !Send for Interpreter<'a, T>

impl<'a, T> !Sync for Interpreter<'a, T>

impl<'a, T> Unpin for Interpreter<'a, T> where
    <T as Grammar>::Lit: Unpin

impl<'a, T> !UnwindSafe for Interpreter<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.