A bottom-up intuitive explanation of Pratt parsing, building from first principles. Starting with how abstract syntax trees encode operator precedence, the post develops the geometric insight that trees lean left for decreasing precedence and right for increasing precedence. When precedence drops, the parser walks back up the spine to find the correct insertion point — this walkback procedure is Pratt parsing. The post walks through pseudocode evolving from a simple recursive descent parser to the full Pratt parser, then extends it to handle right-associativity via separate left and right binding powers (LBP/RBP).
Sort: