pyparsing’s backtracking was the latency ceiling (~3.2k parses/sec). How we identified it, built a hand-written recursive-descent parser with pyparsing as a live parity check, and caught 22 edge cases along the way.
The Scryfall query language implicitly ANDs adjacent terms — pyparsing does not. This post covers the preprocessing layer built on top: implicit AND injection, query balancing in two languages, and the edge cases that required fixes.
How I evaluated parsing approaches for Scryfall’s query language: why regex and ANTLR were ruled out, how Lark compares to pyparsing, and why pyparsing won.