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:
~2.5x faster than liteparser (wasm)
~6x faster than @guanmingchiu/sqlparser-ts (wasm)
~10x faster than node-sql-parser
~100x faster than pgsql-ast-parser
~200x faster than sqlite-parser
~250x faster than @appland/sql-parser
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...