Chibicc: A Small C Compiler
github.com
github.com
> When I find a bug in this compiler, I go back to the original commit that introduced the bug and rewrite the commit history as if there were no such bug from the beginning. This is an unusual way of fixing bugs, but as a a part of a book, it is important to keep every commit bug-free.
Ooo la la! "Chibicc Vol. II, The Bugs" !?
In all seriousness, a book about the bugs would be (IMO) even more fun to read than the compiler book.
* http://www.ccs.neu.edu/course/cs4410/
* https://ucsd-cse131-f19.github.io/
* https://jeapostrophe.github.io/courses/2017/spring/406/notes...
Probably best know and with loooong beard...
This is what I think of when I see Small C as a proper noun.
This generation, CPM support and everything: https://archive.org/details/dr_dobbs_journal_vol_09/page/n33...
nice
Is there any similar project like this where LLVM IR is used? I’ll start building a language just for fun during weekends and I plan to use LLVM but it is rather hard to understand clang on limited time, so a smaller scale project would be awesome.
When it comes to both parsing and emitting IR, keep it simple (stupid!) - the difficult bit (on a day to day basis) with the compiler is almost always the language semantics, the backend is more theory-dense but to just implement a language you can use LLVM as a black-box.
If you minimise mutable state and utilise lowering (you can implement foreach by lowering the AST to a for loop, for example) your compiler will be much easier to debug.
Somehow I can't imagine Brian Kernighan or Dennis Ritchie making those sorts of commits.
I doubt Brian Kernighan or Dennis Ritchie put all the errata at the end of their books on subsequent printings. They fixed the main text.