https://github.com/kondrak/tinyexpr-rs
Tiny recursive descent expression parser, compiler, and evaluation engine for math expressions.
https://github.com/kondrak/tinyexpr-rs
evaluation-engine math-expressions rust tinyexpr-rs
Last synced: about 1 month ago
JSON representation
Tiny recursive descent expression parser, compiler, and evaluation engine for math expressions.
- Host: GitHub
- URL: https://github.com/kondrak/tinyexpr-rs
- Owner: kondrak
- License: mit
- Created: 2016-09-03T15:26:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-07-11T21:31:03.000Z (almost 2 years ago)
- Last Synced: 2025-03-26T10:21:12.603Z (about 2 months ago)
- Topics: evaluation-engine, math-expressions, rust, tinyexpr-rs
- Language: Rust
- Size: 31.3 KB
- Stars: 11
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tinyexpr-rs
[](https://crates.io/crates/tinyexpr)
[](https://docs.rs/tinyexpr)
[](https://github.com/kondrak/tinyexpr-rs/actions/workflows/rust.yml)
[](https://coveralls.io/github/kondrak/tinyexpr-rs?branch=master)
Tiny recursive descent expression parser, compiler, and evaluation engine for math expressions.
This is a WIP port of [TinyExpr](https://github.com/codeplea/tinyexpr) to Rust. Current release only supports built-in system functions (trigonometry, algebraic operations, constants, etc.). See the `tests` module for more examples.
[Documentation](https://docs.rs/tinyexpr)
Usage
-----
```toml
# Cargo.toml
[dependencies]
tinyexpr = "0.1"
```Example
-------
```rust
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 custom user functions
- support functions taking more than 2 parameters
- support closures## License
Licensed under either of
* Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)