Meet `inator`, an evil parsing library

146 points lesturge

Hi all! Second post here. A pet project turned out way better than I thought it could, so I'm humbly sharing it here for all to use:

You supply the evil plan; we supply the -inator

What's different about this parsing library?

  • Pure Rust (no macros, no new syntax)
  • Declarative parsing (e.g. ignore('(') + p + ignore(')') accepts whatever p would accept, but now in parentheses)
  • Zero-copy ("streaming") parsers for free
  • Provably optimal code with automata minimization (see the readme for details)
  • Optional transpiler to Rust source (e.g. in build.rs, so it's always as fast as a hand-rolled implementation but infinitely customizable)
  • Automatically generates random valid input (e.g. if you parse a programming language, you can generate all possible valid source files for free!)

I'm no parsing researcher (just an undergrad), so I'm sure none of this is new, but in practice this fixes all my usual frustrations with parsing libraries—plus, automatic input generation has been invaluable in property testing for me.

Hope it's useful to some of you out there!

Portrait of the eminent Dr. Heinz Doofenshmirtz