GopherCon 2022: Parsing w/o Code Generators: Parser Combinators in Go with Generics - Jeremy Brown @GopherAcademy
GopherCon 2022: Parsing w/o Code Generators: Parser Combinators in Go with Generics - Jeremy Brown  @GopherAcademy
Uploaded November 2022 | Updated December 2026, 3 days ago
For reasons too tedious to print here, I needed to write an extensible Markdown parser. (OK, since you asked, I needed it to implement the software project planning language for DoomCheck). Just as I finished, the first beta release of Go with generics came out, so I did it all again!

Now I’m here to take you on the same journey. Not the Markdown part – Markdown is a parsing nightmare – the parser combinators part.

Parser combinators are a composable way of building parsers in code; they stand in contrast to traditional parser generators like goyacc. They work particularly well in Go now that Go has generics, and they are remarkably easy to implement from scratch. In this tutorial, I’ll do a quick introduction to parser combinators, show you how to use a few primitives to implement a parser for a microlanguage, and dive under the abstraction layer and show you how to implement all the primitives -- each in just a few lines of Go. I aim to give you an appreciation for both parser combinators as an approach to parsing, and for how much better Go generics have made life.

Finally, while I have had a great experience with Go generics overall, there are some frustrating limits around how you can use generics, so in the wrap-up, I will briefly talk about how future versions of Go could increase generics usability for this sort of domain.

Coda: it may make a few readers happy to know that this talk will not include the following words or phrases: Functional Programming, monads, CAML, and Haskell.
GopherCon 2022: Parsing w/o Code Generators: Parser Combinators in Go with Generics - Jeremy BrownGopherCon 2021: Rethinking How We Test Our Async Architecture - Tom LyonsGopherCon 2021: Hugo + go:embed = Your Website as an Executable - Amit SahaGopherCon 2023: A Small Update About TinyGo - GopherCon 2023 Edition - Ron EvansGopherCon 2023: Winning the Latency Arms Race in the Coinbase Golang Trading Engine - Yucong SunGopherCon 2022: Durable Executions in the Face of (some) Failures - Andrew Fitz Gibbon
Gopher Academy |

GopherCon 2022: Parsing w/o Code Generators: Parser Combinators in Go with Generics - Jeremy Brown

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER