finds.dev

matklad/minipratt

View on GitHub

★ 283Rustupdated Nov 2024

// the take

A minimal Rust implementation of Pratt parsing (top-down operator precedence), written specifically to accompany matklad's two blog posts on the topic. This is a teaching artifact, not a library — the code exists to be read alongside the prose, not imported.

The implementation is genuinely minimal: no macros, no trait soup, just ~100 lines that show the core algorithm clearly. Including shunting-yard as a second binary makes the relationship between the two algorithms concrete rather than abstract. matklad is the author of rust-analyzer, so the code quality and idiom choices are trustworthy. Ports to TypeScript and Python exist if you want to compare across languages.

There is no real API surface — you cannot use this as a dependency, you have to copy and adapt the pattern yourself. The repo handles only a toy arithmetic grammar; applying this to a real language with prefix operators, ternaries, or postfix calls requires non-trivial extension that you are on your own for. No tests — correctness is demonstrated only by the example REPL output. Last meaningful commit was years ago, so if the blog posts have errata or the Rust idioms have aged, neither will be updated.

We read the README, the directory tree and a key source file in July 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
283
Forks
16
Language
Rust
Last commit
26 Nov 2024

// nearby

If minipratt isn't quite it.

All repos →