A walkthrough of building a mathematical expression parser in PHP covering three stages: tokenization (splitting a string into numbers and operators), AST construction (building a nested tree that respects operator precedence via a two-pass collapse approach), and recursive execution of the resulting tree. Includes handling of unary minus, complete PHP code for each step, and a working CLI example producing correct results like `2 + 3 * -4 = -10`.

Sort: