The Brief
A spreadsheet vendor is building a formula engine and needs the maths layer first. Build a calculator that takes a string expression and returns its numeric value. Operator precedence, parentheses, unary minus, and named functions are all in scope.
Supported operators: +, -, *, /, // (integer division), %, ** (right-associative). Parentheses for grouping. Unary plus and minus. Named function calls: sqrt, abs, min, max, floor, ceil, round, sin, cos, log. Constants: pi, e.
No eval(). No ast.literal_eval(). No third-party parser libraries. Tokenize the input yourself, then parse and evaluate with recursive descent.