pgpg-experiments
March 1, 2026 ยท View on GitHub
This is a template package for experimenting with the Pretty Good Parser
Generator. One Go module at the repo root depends on
github.com/johnkerl/pgpg/go; each subdirectory is a separate example app.
Build
From the repo root:
go build -o ast-print/ast-print ./ast-print
go build -o json-stream/json-stream ./json-stream
go build -o pascal-s/pascal-s ./pascal-s
go build -o pemdas-eval-gen/tryparse ./pemdas-eval-gen
See each subdirectory's README.md for how to run and regenerate.
Updating the pgpg dependency
When new versions of PGPG are tagged (e.g. go/v0.2.0), from the repo root:
go get github.com/johnkerl/pgpg/go@v0.2.0
go mod tidy
Using one app as a template
To start your own project from one of these apps: copy the app directory (e.g. pemdas-eval-gen/)
into a new repo, add a go.mod at the root with module your-module-name-goes-here, and require github.com/johnkerl/pgpg/go v0.1.0 (or the latest version). Then change that app's imports from
github.com/johnkerl/pgpg-experiments/... to <your-module>/generated/... so the single main
package builds under your module.
Co-developing with PGPG
To work on pgpg-experiments and pgpg in parallel (e.g. developing/tweaking the pgpg library
while testing in these apps), use a go.work file so the Go toolchain uses your local pgpg checkout
instead of the published module.
-
Clone both repos as siblings:
git clone https://github.com/johnkerl/pgpg git clone https://github.com/johnkerl/pgpg-experimentsso you have
pgpg/andpgpg-experiments/next to each other. -
Create
go.workin the pgpg-experiments root:cd pgpg-experiments go work init . go work use ../pgpg/goOr create it manually:
go 1.25 use ( . ../pgpg/go ) -
Build and run as usual. The workspace makes
go buildandgo testuse your local pgpg code. -
Do not check
go.workorgo.work.sumin to source control. It's listed in.gitignore. Each developer creates their own when needed. -
To switch back to the published module, remove or rename
go.work. To temporarily suppress,export GOWORK=offfor your current terminal session.