#expression-parser #parser #expr #math

bin+lib exprs

A 0 dependency math expression parser and evaluator in Rust. It aims to be simple to use and is more of an exercise than anything.

2 releases

0.1.1 Nov 22, 2022
0.1.0 Nov 22, 2022

#15 in #expr

WTFPL license

18KB
375 lines

exprs

A 0 dependency math expression parser and evaluator in Rust. It aims to be simple to use and is more of an exercise than anything.

Quick Start

Parsing an expression is simple

use exprs::*;

fn main() {
    let expr = Expr::new("1 + 2");
 
    let computation = expr.eval();

    assert_eq!(computation, 3.0);
}

Installation

Simply add the current version to your Cargo.toml dependency list

[dependencies]
exprs = "0.1"

in your crate root add

extern crate exprs;

TODO

  • More robust parse errors rather than assert macros

lib.rs:

exprs

A 0 dependency math expression parser and evaluator in Rust. It aims to be simple to use and is more of an exercise than anything.

Evaluating Expressions

use exprs::*;

fn main() {
    let expr = Expr::new("1 + 2");
    
    assert_eq!(expr.eval(), 3.0);
}

Installation

Simply add the current version to your Cargo.toml dependency list

[dependencies]
exprs = "0.1.1"

in your crate root add

extern crate exprs;

No runtime deps