编译器的编写之旅
A Compiler Writing Journey

原始链接: https://github.com/DoctorWkt/acwj

这个Github仓库详细记录了作者构建一个C语言子集SubC的自编译编译器的过程。该项目最初是作为对编译理论的实践探索,从词法扫描和解析开始,逐步记录了函数、循环、结构体甚至预处理器等复杂功能的实现。 编译器最初的目标是ARM汇编,后来扩展到包含6809 CPU的后端,以及使用QBE的新后端。开发过程中涉及多次迭代、错误修复和优化,包括寄存器溢出和常量折叠。 虽然SubC现在基本完成,但作者已经转向一个新的语言项目alic,利用了SubC的一些想法和代码(并对Nils M Holm的公共领域作品进行了适当的许可声明)。仓库中的代码采用GPL3许可,而文档采用知识共享署名-非商业性使用-相同方式共享4.0许可。

黑客新闻 新 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 编译器写作之旅 (github.com/doctorwkt) 8 分,ibobev 发表于 51 分钟前 | 隐藏 | 过去 | 收藏 | 讨论 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系 搜索:
相关文章

原文

In this Github repository, I'm documenting my journey to write a self-compiling compiler for a subset of the C language. I'm also writing out the details so that, if you want to follow along, there will be an explanation of what I did, why, and with some references back to the theory of compilers.

But not too much theory, I want this to be a practical journey.

Here are the steps I've taken so far:

I've stopped work on acwj and now I'm writing a new language called alic from scratch. Check it out!

I have borrowed some of the code, and lots of ideas, from the SubC compiler written by Nils M Holm. His code is in the public domain. I think that my code is substantially different enough that I can apply a different license to my code.

Unless otherwise noted,

  • all source code and scripts are (c) Warren Toomey under the GPL3 license.
  • all non-source code documents (e.g. English documents, image files) are (c) Warren Toomey under the Creative Commons BY-NC-SA 4.0 license.
联系我们 contact @ memedata.com