[−][src]Struct arithmetic_eval::Interpreter
Simple interpreter for arithmetic expressions.
Implementations
impl<'a, T> Interpreter<'a, T> where
T: Grammar,
[src]
T: Grammar,
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]
&mut self,
name: &'a str,
native_fn: impl NativeFn<T> + 'static
) -> &mut Self
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]
T: Grammar,
T::Lit: Num + Neg<Output = T::Lit> + Pow<T::Lit, Output = T::Lit>,
pub fn evaluate(
&mut self,
block: &Block<'a, T>
) -> Result<Value<'a, T>, ErrorWithBacktrace<'a>>
[src]
&mut self,
block: &Block<'a, T>
) -> Result<Value<'a, T>, ErrorWithBacktrace<'a>>
Evaluates a list of statements.
pub fn compile(
&self,
program: &Block<'a, T>
) -> Result<ExecutableModule<'a, T>, SpannedEvalError<'a>>
[src]
&self,
program: &Block<'a, T>
) -> Result<ExecutableModule<'a, T>, SpannedEvalError<'a>>
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]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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]
T::Lit: Num + Neg<Output = T::Lit> + Pow<T::Lit, Output = T::Lit>,
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,
<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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,