《编写C编译器》封面

编写C编译器

Writing a C Compiler

Nora Sandler · 初版 2023 年

7人推荐
7位读者提及
10次提及

这是一本寓教于乐的实战指南,教你如何为一门真实的编程语言亲手编写编译器。编译器处于程序员一切工作的核心,但即使是经验丰富的开发者也常对其心生敬畏。对于渴望真正理解编译器运作机制的人来说,Writing a C Compiler 将为你拨开迷雾。本书将带你完成一个趣味盎然的项目,学习将一门现实世界的编程语言编译为真实汇编代码所需的知识。Writing a C Compiler 将按部就班地引导你为 C 语言的一个重要子集构建专属于你的编译器——无需事先具备任何相关经验

Hacker News 上怎么说

  • 没错。我最喜欢的就是那种一步一步手把手教你从零实现复杂系统项目的书,比如诺拉·桑德勒(Nora Sandler)的《动手写 C 语言编译器》(Writing a C compiler),或者 Sy Brand 的《动手写调试器》(Building a Debugger)。真希望他们能多出大大大大一大堆这种书。

    Yeah. My favorite are books that guide you through implementing complex systems projects from scratch, like Nora Sandler's "Writing a C compiler", or Sy Brand's "Building a Debugger". I wish they produced A LOT more of them.

  • Bob Nystrom 的《Crafting Interpreters》是一个很好的入门起点。等你积累了一些经验之后,就可以尝试死磕 Nora Sandler 的《编写 C 编译器》了。

    A good place to start is "Crafting interpreters" by Bob Nystrom. Then, after you gain some experience, you could try tackling Nora Sandler's "Writing a C compiler".

  • 你可能会对这个感兴趣:Nora Sandler 写的《编写 C 编译器》(No Starch Press 出版)。在第一章你就能写出一个能输出 x64 汇编语言、可正常工作的 C 编译器(只要程序只在 main 里返回一个整数就行),然后接下来你会继续……

    This might interest you: Writing a C Compiler by Nora Sandler (No Starch Press). You create a working C compiler that outputs x64 assembly language in the first chapter (as long as the program only returns an integer from main) and then you keep…

  • ……楼主提到的那些概念(活跃性分析、常量折叠、死代码消除),以及围绕 IR 优化的类似知识点,都能在 Nora Sandler 的《编写 C 编译器》中找到极其详尽的解释。

    …concepts that the OP talks about (liveness analysis, constant folding, dead code elimination), and similar stuff revolving around IR optimization, can be found explained in great detail in Nora Sandler's "Writing a C compiler".

  • 如果你喜欢 Ghuloum 的论文,有三本受其启发、出版时间相对较新的编译器图书:https://nostarch.com/writing-c-compiler - Nora Sandler 写的《编写 C 编译器》,实现上不限定编程语言。https://mitpress.mit.edu/9780262047760/essentials-of-compila... - Jeremy Siek 写的《编译原理要素》(使用 Racket)https://mitpress.mit.edu/9780262048248/essentials-of-compila...……

    If you like Ghuloum's paper, there are three fairly recent compiler books that are inspired by it: https://nostarch.com/writing-c-compiler - Writing a C Compiler by Nora Sandler, language agnostic for the implementation. https://mitpress.mit.edu/9780262047760/essentials-of-compila... - Essentials of Compilation (using Racket) by Jeremy Siek https://mitpress.mit.edu/9780262048248/essentials-of-compila...…

  • ……处理内存栈的指令。但它比 x86_64 之类的东西清晰干净多了。如果你有兴趣深入了解如何编写 C 编译器,我强烈推荐 Nora Sandler 写的《编写 C 编译器》这本书[0]。这是一本超级详尽的渐进式指南,教你如何编写 C 编译器。它还采用了传统的多 pass 架构。它使用了自己名为 Tacky 的 IR,并且……

    …instructions to handle the memory stack. But it's much more cleaner than something like x86_64. If you are interesting in learning in more detail how to write a C compiler, I highly recommend the book "Writing a C Compiler" by Nora Sandler [0]. This is a super detailed, incremental guide on how to write a C compiler. This also uses the traditional architecture of using multiple passes. It uses its own IR called Tacky and…

正在加载完整评论……

键盘快捷键

/
聚焦搜索框
j / k
下一本 / 上一本
Enter
打开选中的书
Esc
关闭 / 返回
g h
回到首页
g b
值得读精选
g t
历史总榜
g r
上升最快
g l
我的书架
?
显示本帮助