finds.dev← search

// the find

chai2010/go-ast-book

★ 5,509 · Go · updated Sep 2024

:books: 《Go语言定制指南》(原名:Go语法树入门/开源免费图书/Go语言进阶/掌握抽象语法树/Go语言AST)

A Chinese-language book (with working code) that walks through Go's AST packages — go/token, go/ast, go/parser, go/printer — then extends into writing DSLs, goyacc grammars, LLVM IR generation, and the author's own Wa language targeting WebAssembly. It's aimed at Go developers who want to write static analysis tools, code generators, or toy compilers, and who read Chinese.

The progression is genuinely well-structured: tokenizer → AST nodes → type checker → code generator, each chapter paired with runnable examples you can step through. The appendices covering goyacc, ANTLR4, and LLVM IR are more practical than most intro compiler texts. The working example set (ch1–ch14) is dense enough that you can copy-paste and experiment without fighting a broken scaffolding. The connection to a real shipping language (Wa/WebAssembly) gives the later chapters concrete grounding instead of toy-problem hand-waving.

The book is entirely in Chinese — not a criticism of quality, but it is a hard filter that rules out most of the global Go audience. Chapters 15 and 16 are skeletal (just .keep files and stub READMEs), so the WebAssembly backend section is unfinished. There are no tests anywhere in the example code, which matters when you're learning a domain where subtle bugs are hard to spot. The last substantive push was September 2024 but the book was written across several years, so some Go AST API notes (especially around generics) may be stale.

View on GitHub → Homepage ↗

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →