#expression #expression-parser #parser

tinyexpr

Tiny recursive descent expression parser, compiler, and evaluation engine for math expressions. A work in progress port of TinyExpr library to Rust.

2 releases

Uses old Rust 2015

0.1.1 Dec 30, 2016
0.1.0 Dec 30, 2016

#117 in #expression-parser

MIT/Apache

25KB
528 lines

tinyexpr-rs

Crates.io Documentation Build Status Build status Coverage Status

Tiny recursive descent expression parser, compiler, and evaluation engine for math expressions.

This is a WIP 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.

Documentation

Usage

# Cargo.toml
[dependencies]
tinyexpr = "0.1"

Example

extern crate tinyexpr;

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

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

Build instructions

cargo build
cargo run --example tinyexpr

Todo

  • support for custom user function
  • support for functions taking more than 2 parameters
  • support closures

License

Licensed under either of

Dependencies

~145KB