5 releases (3 breaking)

0.4.1 May 25, 2021
0.4.0 May 25, 2021
0.3.5 May 7, 2021
0.2.1 May 7, 2021
0.1.0 May 7, 2021

#2724 in Parser implementations

MIT license

20KB
505 lines

calc_engine

This Engine transforms a string representation of a Math expression to the actual result of the expression.

I'm using the top-down recursive descent parsing techque. (Input is read from Left -> Right)

How to use.


use calc_engine;

func main() {
    let res = calc_engine::calculate("1 + 1")?;
    let error_margin = f64::EPSILON;
    assert!((result - 2.0).abs() < error_margin);

    let res = calc_engine::calculate("(1 + 1) + 3")?;

}

Still to be done

  • Bug fixes
  • Logarithmic expressions
  • More tests..

Not in any particular order.

Dependencies

~13KB