"Parsing Expression Grammars (PEG)"
summary
A go.mod parser is built in about 20 minutes using PEGs and Pigeon (github.com/MNA/pigeon) to generate Go code, with go generate driving regeneration and action blocks producing go.mod manifest structs from parsed text. Tests drive the grammar evolution from a permissive any-character rule to rules that parse module name, go version and single or parenthesized dependency lists. Noteable details: conversion pain from pigeon returning []interface{} and earlier regex-to-parser work improving render times by two orders of magnitude.
AI-written summary · about
chapters (7)
- 0:00Start
- 1:13Let's use regexes!
- 3:14Parsing Expression Grammars
- 4:30Project Layout
- 7:37Tests!
- 13:24Parsing Dependencies
- 15:33Multiple Dependencies
related talks
39mLogic Programming in Go
16mTools for working with Go Code
26mTime to Go with PostgreSQL
24m"Finding Dependable Go Packages"
39mIs Go A Good Language to Build Compilers?
51mBuilding Generative AI Applications in Go- Gari Singh, Google (Part 2)
38mUsing Go Modules in everyday life
32mBuilding a Beginner's Programming Language with Go
