Writing that changed how I think about PL

55 points by surprisetalk


ahelwer

Parsing expressions by precedence climbing

A good one! I feel like a lot of recursive descent parser authors end up writing something like it after deciding life is too short for 15 separate functions that all look the same. It’s used in TLA+, a weird language where operators have precedence ranges. The pattern handles that gracefully too, you just recurse with the precedence parameter set to the upper end of the currently-matched-operator’s precedence range.