Expression Parser in PHP (token → AST → execution)
A step-by-step guide to building an expression parser in PHP that converts mathematical strings into executable code. The tutorial covers three core phases: tokenization (splitting strings into numbers and operators while handling unary minus), AST construction (building an Abstract Syntax Tree using a two-pass collapse algorithm to respect operator precedence), and recursive evaluation (executing the tree from leaves to root). Includes complete working code examples demonstrating how to parse and evaluate expressions like "2 + 3 * -4" correctly.