Overview
Pratt parsing gives tokens prefix and infix parse behavior and uses binding power to decide when an expression should stop consuming operators. It is compact for expression-heavy grammars.
Parses expressions by assigning binding powers to tokens and recursing by precedence.
Compact metadata for implementation and discovery.
Pratt parsing gives tokens prefix and infix parse behavior and uses binding power to decide when an expression should stop consuming operators. It is compact for expression-heavy grammars.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n)
Worst
O(n)
Space
O(d)
Show operators grabbing operands according to binding power.
Pratt parsers are concise, but binding-power tables need careful tests.
What each reference supports for this entry.
Original Pratt parsing reference for binding-power driven expression parsing.
Open sourceParsing reference for Pratt Parsing's control flow, grammar assumptions, and parser construction tradeoffs.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Parsing · Foundation
Pratt parsing is a recursive-descent technique specialized for expressions.
Compare with thisParsing · Core
Pratt parsing handles precedence directly, while the two-stack form assumes full parenthesization.
Compare with thisParsing · Core
Operator-precedence parsing and Pratt parsing are expression parsers with different control structures.
Compare with thisPratt parsing is a recursive-descent technique specialized for expressions.
Both parse expressions by precedence, but organize the recursion differently.