Repository navigation
Initial pre-release v0.1.0-alpha
Pre-release
Pre-release
Calculator api in rust. Takes a String-term and calculates the result. Currently supported Operands:
- addition (+)
- subtraction (-)
- multiplication (*)
- division (/)
- modulo (%)
As well as Parenthesis with the normal round ones () but also the square brackets [].
It is basically an Implementation of the Shunting Yard Algorithm by the goat Edsger W. Dijkstra
the standard function is
fn eval(expression: &String) -> Result<u32, String>
which takes a String and returns the result as a Result<u32, String>
If you want a bit verbosity then there is:
fn verbose_eval(expression: &String, verbosity: u8) -> Result<u32, String>
which also takes a value between 1 and 4 that determinate the amount of logging it does
- 1 prints the shunting yard output stack and all of the above.
- 2 prints the operator stack of shunting yard and all of the above.
- 3 prints the stack of the solver and all of the above
- 4 prints the expression stack of the function that turns the string into a stack and all of the above
Did not check for any typing and grammar errors