[−][src]Trait gameshell::Evaluate
Interpreter trait
Central trait to add the interpreter to your custom evaluator
Required methods
fn evaluate(&mut self, statement: &[Data<'a>]) -> T
Evaluate a single statement
Statements are line-separated pieces of code turned into fixed data
segments. See interpret_single
and interpret_multiple
on how to
parse statements.
Provided methods
fn interpret_single(&mut self, statement: &str) -> Result<T, ParseError>
Set up the parser and call evaluate on the result
This method expects 1 single statement, that is, it doesn't take in a bunch of separate statements, but rather one single whole statement, even if it contains newlines, which are considered whitespace and skipped.
fn interpret_multiple(&mut self, code: &str) -> Result<T, ParseError>
Interpret several statements one-by-one
When calling this function, it will interpret
each individual statement,
Normally, this happens when a newline is found. If however that same line contains
an unclosed opening parenthesis, we will need to include some lines coming after this one
in order to complete the statement.