Crate pupil

Crate pupil 

Source
Expand description

§Arithmetic expression evaluator

Simple usage:

// Create a basic environment with the default builtins
let mut env = pupil::BasicEnv::default();

// Evaluate expressions in this environment
let result = pupil::eval(&env, "2 + 3");
assert_eq!(result, Ok(5.0));

Structs§

BasicEnv
Basic environment.
Error
Error structure.
Expr
Expression context.
Token
Token structure.

Enums§

ErrorKind
Error kinds.
Operator
Supported operator types.
TokenKind
Token kinds.

Traits§

Env
Environment interface.

Functions§

eval
Evaluates and calculates the result in one step.
eval_tokens
Evaluates a list of tokens and calculates the result.
function
Looks up a native function by name.
tokenize
Creates an iterator over the tokens in a string.

Type Aliases§

Function
Signature for native functions.
Value
Underlying type used for arithmetic.