I needed a SQLite parser small and fast enough to use in Notion's UI thread that I can trust will handle modern SQLite syntax. The most-downloaded SQLite parser on NPM is unfortunately unmaintained and slow, and while there are some fast and accurate WASM options, WASM pays a very large start-up cost as well as per-call overhead. SQLite uses a LALR(1) parser generator call Lemon (similar to Yacc). I patched Lemon to dump its parse tables to JSON, then ported SQLite's [parse.y][] grammar to TypeScript with some help from Claude. The result is this library, which I think is the fastest JavaScript SQL parser out there:
This shipped in Notion a few weeks ago and cleared up some sporadic crash reports where the library we previously used choked on valid input.parse.y: https://github.com/justjake/sqlite3-parser-js/blob/main/vend... |
No comments yet