acwj README

The project's README from github.com/DoctorWkt/acwj. As one markdown file: README.md.

A Compiler Writing Journey

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!

Copyrights

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,

acwj (DoctorWkt/acwj)

Searching Database…

13.5K ·GitHub
这是什么?这是一套有文字说明的教程系列,作者用它构建一个能自我编译的 C 语言子集编译器。全套内容分为大约 64 个循序渐进的部分,每一部分都有可运行的源代码,并附有解释其背后原理的文字。
这是一个能用的编译器,还是只是教程?两者兼有。每个编号部分都会为一个不断增长的编译器添加真实的 C 源代码,并配有说明改动内容及原因的文字,所以你最终既能得到一个可以正常工作的编译器,也能了解它是如何一步步构建出来的。
我应该从哪里开始读?从第0部分(旅程简介)开始,按顺序阅读,直到第64部分;每一部分的代码都直接建立在前一部分的基础上。
跟着学需要什么特别的东西吗?只需要一个 C 编译器和基本的 C 语言知识。项目本身完全用 C 编写,没有外部依赖,除了标准工具之外,不需要 Docker 或其他构建系统。
这个项目还在持续更新吗?不了,作者已停止为 acwj 添加新的部分,转而从零开始编写一门名为 'alic' 的全新语言。
整个仓库都使用同一个许可证吗?不是。源代码和脚本使用 GPL-3.0 许可证,而英文文档和图片则单独使用 Creative Commons BY-NC-SA 4.0 许可证,后者限制对文字内容的商业再利用。
这个编译器生成的是哪种目标代码?从第14部分左右开始,它直接生成 ARM 汇编代码;后续部分还增加了基于 QBE(第63部分)以及面向 6809 CPU(第64部分)的其他后端。
它能编译整个 C 语言吗?不能,它只支持一个经过刻意限制的 C 语言子集,刚好足够让编译器实现自举,也就是最终能够编译它自己的源代码。
作者是每一部分都从零写的吗?并不完全是。部分代码和很多思路借鉴自 Nils M Holm 的公有领域 SubC 编译器,不过作者认为最终成果已经与之有足够大的差异,因此单独授权。
Creator
DoctorWkt
Size
4 MB
Stars
13.5K
Updated
CommitJun 06
Age
7y
Commits · 90 Days