Packrat Parsing at the Speed of Wasm
Ohm is a parsing toolkit for JavaScript and TypeScript that we originally created to support our own PL research. Over the years, we’ve implemented its packrat parsing engine three different ways: as a tree-walking interpreter, a bytecode interpreter, and most recently, compiled to WebAssembly.
This talk traces that evolution, with a focus on the latest Wasm implementation. In Ohm v18, each grammar is compiled to a specialized Wasm module — a purpose-built parser with one function per rule. Compared to the JavaScript version, this has led to 20x faster parse times on real-world grammars (e.g. ES5) with about 20% of the memory usage.
I’ll go into details on several important design decisions that made this improvement possible, and about aspects of Ohm’s original design that made it challenging. I’ll also cover packrat parsing more broadly, and talk about how memoization enables a couple key features in Ohm: left recursion and incremental parsing.
Independent software engineer and researcher based in Munich, Germany. Co-creator and maintainer of Ohm, a user-friendly parsing toolkit for JavaScript and TypeScript. Writing WebAssembly from the Ground Up.
Tue 17 MarDisplayed time zone: Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna change
09:00 - 10:00 | |||
09:00 60mKeynote | Packrat Parsing at the Speed of Wasm MoreVMs Patrick Dubroy WebAssembly from the Ground Up | ||
