Crate mexprp [−] [src]
MEXPRP
A math expression parsing and evaluating library
Usage
The recommended way to use it is with the Expression struct, but it can also be used for one-off
usages with the eval()
and eval_ctx()
functions in the root. Expressions can be parsed without
a context and will use the default one, but in order to use custom constants and functions, Expressions
need to be parsed AND evaluated with the context you wish to use.
Evaluating an expression
mexprp::eval("10 / (2 + 3)"); // Ok(2.0)
Compiling an expression
let expr = Expression::parse("3 ^ 4 / 9").unwrap(); let res = expr.eval(); // Ok(9.0)
Re-exports
pub use func::Func; |
pub use expr::Calculation; |
pub use expr::Expression; |
pub use expr::Term; |
pub use context::Context; |
Modules
context |
Context struct |
errors |
All the errors |
expr |
Contains expressions and terms |
func |
Contains Function trait |
op |
Contains definitions for Operations |
opers |
Contains implementations for operations |
parse |
Contains methods for parsing equations into token representations |
Functions
eval |
Parse and evaluate a string |
eval_ctx |
Parse and evaluate a string with the given context |