Loading…
Evaluating a mathematical expression given as text, precedence included.
A pared-down version of the calculator problem: the program receives an expression as a string of characters and must return the result. What seems trivial to a human requires the machine to understand that multiplication comes before addition, that parentheses change the order, and that a minus sign may be a subtraction or a negation.
An eval_expr binary converting an infix arithmetic expression into reverse Polish notation through shunting-yard, then evaluating it while respecting precedence and nested parentheses.
READING SOURCE…