Crate tinyexpr [] [src]

TinyExpr is a tiny recursive descent expression parser, compiler, and evaluation engine for math expressions. This is a work in progress port of TinyExpr to Rust.

Current release only supports built-in system functions (trigonometry, algebraic operations, constants, etc.). See the tests module for more examples.

Quick Start

extern crate tinyexpr;

fn main()
{
    // parse the expression and fetch result
    let r = tinyexpr::interp("2+2*2").unwrap();

    // should print "6"
    println!("{:?}", r);
}

Modules

error

Error type for tinyexpr crate.

Constants

TE_CLOSURE0
TE_CLOSURE1
TE_CLOSURE2
TE_CLOSURE3
TE_CLOSURE4
TE_CLOSURE5
TE_CLOSURE6
TE_CLOSURE7
TE_CONSTANT
TE_FLAG_PURE
TE_FUNCTION0
TE_FUNCTION1
TE_FUNCTION2
TE_FUNCTION3
TE_FUNCTION4
TE_FUNCTION5
TE_FUNCTION6
TE_FUNCTION7
TE_VARIABLE
TOK_CLOSE
TOK_END
TOK_ERROR
TOK_INFIX
TOK_NULL
TOK_NUMBER
TOK_OPEN
TOK_SEP
TOK_VARIABLE
T_MASK

Functions

interp

Interprets a string expression as a mathematical expresion, evaluates it and returns its result.