finds.dev← search

// the find

matklad/minipratt

★ 283 · Rust · updated Nov 2024

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.

View on GitHub →

// want more like this?

Every week we dig through GitHub and send you a few repos picked for what you're working on, each with an honest take like this one. Free. See a real issue →

// similar repos

Search the finds →