pub struct Evaluator<'a, C> { /* private fields */ }
Expand description
The virtual machine that runs commands
The virtual machine interprets strings and provides an output. It operates on the strings according to the specified mapping table, which can be manipulated via Evaluator::register and Evaluator::register_many.
Builting commands are autocomplete
, which tries to look ahead by 1 query, and ?
which lists
all possible queries.
Implementations§
source§impl<'a, C> Evaluator<'a, C>
impl<'a, C> Evaluator<'a, C>
sourcepub fn new(context: C) -> Self
pub fn new(context: C) -> Self
Create a new VM which owns a context
. The context is used in handler functions and can be
mutated.
sourcepub fn set_recursion_limit(&mut self, limit: usize)
pub fn set_recursion_limit(&mut self, limit: usize)
Set the recursion limit of nested calls.
sourcepub fn context_mut(&mut self) -> &mut C
pub fn context_mut(&mut self) -> &mut C
Get a mutable reference to this machine’s context.
sourcepub fn register(
&mut self,
spec: Spec<'_, 'a, Type, String, C>
) -> Result<(), RegError>
pub fn register( &mut self, spec: Spec<'_, 'a, Type, String, C> ) -> Result<(), RegError>
Register a handler function for a command.
sourcepub fn register_many(
&mut self,
spec: &[Spec<'_, 'a, Type, String, C>]
) -> Result<(), RegError>
pub fn register_many( &mut self, spec: &[Spec<'_, 'a, Type, String, C>] ) -> Result<(), RegError>
Register an array of handler functions for a command, see Evaluator::register.
Trait Implementations§
source§impl<'a, C> Evaluate<Result<String, String>> for Evaluator<'a, C>
impl<'a, C> Evaluate<Result<String, String>> for Evaluator<'a, C>
source§fn evaluate(&mut self, commands: &[Data<'_>]) -> Feedback
fn evaluate(&mut self, commands: &[Data<'_>]) -> Feedback
Evaluate a single statement Read more
source§fn interpret_single(&mut self, statement: &str) -> Result<T, ParseError>
fn interpret_single(&mut self, statement: &str) -> Result<T, ParseError>
Set up the parser and call evaluate on the result Read more
source§fn interpret_multiple(&mut self, code: &str) -> Result<T, ParseError>
fn interpret_multiple(&mut self, code: &str) -> Result<T, ParseError>
Interpret several statements one-by-one Read more