Great explanation! I’m a huge fan of parser combinators; I wrote and maintain https://github.com/francisrstokes/arcsecond, and even the first series of videos I made was about building up a PC implementation from scratch (https://www.youtube.com/playlist?list=PLP29wDx6QmW5yfO1LAgO8kU3aQEj8SIrU).
They’re really appealing on multiple levels; they both break down the complexity normally associated with parsing into just some functions, but are also flexible enough to be thrown at both text and binary data. Combine that with higher order operations, and techniques like using coroutines for async-await style parsing, and you’ve got one very powerful tool. Years later, and they’re still my go-to for anything beyond the simplest of regular expressions
I’ve just started using Pratt parser techniques, which are also great. I wonder if they can be combined with parser combinators, for even more goodness…
They can! For example, Elm has a parser combinator library (elm/parser) and there’s a library adding Pratt parsing combinators: https://package.elm-lang.org/packages/dmy/elm-pratt-parser/latest/