Pratt parsing is a black box
Web page · https://vinipsmaker.github.io/blog/article/pratt-parsing-is-a-black-box
First seen by Oriel on .
AI summary
The article argues that effective Pratt parsing depends more on understanding token roles and binding powers than on studying its compact parsing algorithm.
- Pratt reduces parsing decisions to whether a token expects an expression on its left.
- A nud, or null denotation, expects nothing to its left, while a led, or left denotation, requires something there.
- Unlike traditional parsers that attach semantic actions to production rules, Pratt parsers attach actions directly to terminal tokens.
- The compiler example uses separate dispatch tables for nud handlers, led handlers, and binding powers covering prefixes, operators, calls, indexing, and postfix operations.
- The core algorithm can fit in nine high-level-language lines and has remained unchanged since 1973.
#pratt parsing #compiler design #parsing algorithms
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Points
Score reported by the source.
- Hacker News: 60, latest observation ; +57 over observed period since
- Lobsters: 41, latest observation ; +40 over observed period since
Comments
Comment count reported by the source.
- Hacker News: 32, latest observation ; +32 over observed period since
- Lobsters: 11, latest observation ; +10 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| Hacker News | 50357457 | https://vinipsmaker.github.io/blog/article/pratt-parsing-is-a-black-box/ Read discussion |
| Lobsters | bzazar | https://vinipsmaker.github.io/blog/article/pratt-parsing-is-a-black-box/ Read discussion |