IT Essentials
Parser Combinators: The Space Between Regex and tree-sitter
An explainer of parser combinators: composing small parsing functions to turn text into structured data, and judging when a task is past regex but short of tools like tree-sitter.
From awkward text to structured data
Sooner or later most engineers hit the same wall: a text format that needs to become structured data, but is too tangled for regex and too small to justify heavy parsing machinery. A GeekNews piece highlighted in October 2026 covers parser combinators, a long-standing design technique aimed at exactly this gap.
How composition works
The technique’s core idea is in its name: split the work into small parsing functions and link them together. According to the GeekNews summary, the basic unit is a partial parser that reads some of the input string, produces one parsed value, and hands back the rest of the input alongside it. A parser, in other words, is not a monolithic program that swallows everything at once but a function that consumes a little and passes the remainder on. Composing these small parsers yields a parser for a complex format, and the final product is structured data rather than raw text.
The middle ground between regex and tree-sitter
The most useful part of the piece is the decision rule GeekNews offers: parser combinators fit cases where regex is too complex but tree-sitter is overkill. Regex works well on flat patterns and falls apart as structure nests; grammar-based tools like tree-sitter are powerful for language-level parsing but feel heavy for one small, custom format. Combinators sit in the band between — think a home-grown configuration format or log-style text — where a handful of composed functions can beat both extremes.
Why it still matters
Nothing in the technique is tied to a product, release, or language. Formats change; the principle of building small and composing does not. What remains open are the practical problems every implementer eventually meets — precise error reporting when parsing fails, performance, handling recursive grammars — which go beyond this introduction and stay with the reader. Treat the piece as a concept primer, then continue with a combinator library in whichever language you actually ship.