“Comes in handy for learning how to write compilers ~ Let's Build a Compiler”
Jack W. Crenshaw 的系列教程,从最小的表达式解析器出发,每一章只加一点功能,逐步长成能生成汇编的完整小编译器。全程采用递归下降(recursive descent)和直接生成代码的做法,不依赖 lex、yacc 之类的自动工具,行文口语化、几乎没有形式化理论。代码用 Pascal 写成,年代较久,但思路可以搬到任何语言。和龙书这类系统教材相比,它更像边做边讲的实操手记,适合先建立信心再去读理论。
HN 上的人把它当作编译器入门的首选推荐:认为它让编译器不再吓人,一步步跟着做就行,用什么语言实现都可以;也有人提醒它年代久、用 Pascal,但仍然有启发。
想亲手写第一个编译器的自学者
怎么读
由 Claude 根据这本书和 HN 上的说法整理,可能有错- 1从头按章节顺序读,跟着敲代码,不要跳章
- 2用你熟悉的语言重写示例,不必拘泥于 Pascal
- 3读完再配合一本讲词法、语法分析和优化的教材补理论
- 4把它当第一本编译器读物,别指望覆盖类型系统和现代优化
HN 书评
推荐在前,同类按时间 · 每本最多保留 20 条,统计用全部提及 · 作者本人贴的不算“There's also Jack Crenshaw's classic "Let's Build A Compiler":”
“it was just about perfect for someone who wanted to whip up a nice little compiler for a foogol on a late-1980s DOS box”
“This is similar in spirit to this much more detailed series of text files, which is a great introduction for a beginner:”
“start with _Let's Build a Compiler_ - it'll make compilers seem much less intimidating.”
“Even though it's very dated, Crenshaw's "Let's Build a Compiler" can teach you everything you need to get started building languages from scratch and by hand”
看全部 20 条 →
“Jack Crenshaw's "Let's Build a Compiler" is a good introduction: Let's Build a Compiler”
“i found Jack Crenshaw's "Let's build a compiler" series a good starting reference and source of inspiration [1].”
“Also, this wonderful page too: Let's Build a Compiler”
“If you want an imperative tutorial then the Crenshaw tutorial [1] or Nicklaus Wirth's book Compiler Construction[2] are great starting points.”
“A bit old and it is in Pascal, but still, Let's Build a Compiler by Jack Crenshaw is also fun to read:”
“Jack Crenshaw has a nice series called Let's Build a Compiler.”
“personally I think Jack Crenshaw's tutorial series (started in 1988) is one of the best:”
“Should be at least a good introduction to compilers.”
“"Let's Build a Compiler"[1] by Jack Crenshaw is fantastic.”
“Crenshaw's classic Let's Build a Compiler is a great way to see how it was done even if it is written using Pascal.”
“Hi, for the parser and compiler this helped me a lot: Let's Build a Compiler”
“I'm sure that someone who had never touched programming in their life could learn how to write a compiler from this work.”
“It's an old classic, using somewhat outdated technologies, but there are more moderns versions floating around”
“There's also the (much older but still enlightening) "Let's Build a Compiler" by Jack Crenshaw:”