Every "math evaluator in N lines" article either uses shunting-yard (Dijkstra's stack-based RPN converter) or hand-waves over the hard cases (
-2^2, right associativity, error positions). This one uses recursive descent because the grammar and the code map 1-to-1, which makes the whole thing easier to read and write about. ~250 lines of JS, 36 unit tests, supports functions, variables, constants, parentheses, and reports errors with a column number and a caret.
📦 GitHub: — MIT, ~250 lines of JS + 36 unit tests, zero dependencies, no build step.
🛠 Built by for more.
SOCIAL SHARE CARD GENERATOR