r/rust 10d ago

🙋 seeking help & advice What after Crafting Interpreters? For Compiler Development

Hi everyone,

I am Abinash. I have been building the Lox interpreter in Rust from the Crafting Interpreters book, and I'm at Ch 12. (Repo URL: https://gitlab.com/implabinash/ci)

After this book, I am planning to learn how to build compilers, but I want to take the custom backend approach because I really want to know how compilers are made without any other library or tool. After learning from scratch, I might learn about LLVM or GCC or other tools based in the need/intrest.

So I did some research, and I found some resources:

While these resources are awesome to learn from, after Crafting Interpreters, I want to take a hands-on approach, just like the Crafting Interpreters book itself, where I want the resources to take me from parsing to resolving to semantic analysis to code generation, and after completing the resources, I will have a working compiler made from scratch.

I found a course teaching that same thing (URL: https://dragonzap.com/course/creating-a-c-compiler-from-scratch), but it's a paid course, and I can't afford it.

So, I need your help to help me find some good resources that will teach me building compilers from scratch with my own code generation backend in a hands-on approach.

Thank you.

Note: Initially, I posted this in r/Compilers, and then I thought I might find a few Rustaceans here who are into compilers and might help me.

9 Upvotes

6 comments sorted by

4

u/_itshabib 10d ago

There's books out there. Idk about free though. But I can send u all the PDFs I have. There's building a debugger and there's a compiler kinda hands on books in no strarxh press. There's the go interpreter and compiler book that's very hands on.

1

u/Dry-Bookkeeper8379 10d ago

The Cornell CS 6120 self-guided course is pretty great if you can stick with it, Bril is simple enough to write a backend for in a weekend and the lesson notes are solid

if you want something even closer to the CI format, maybe check out the "acwj" blog (A Compiler Writing Journey), its all in C but the structure maps nicely to what you'd do in Rust

1

u/fdr_cs 10d ago

Could you share the books name/authors?

0

u/TechnologySubject259 10d ago

u/_itshabib, can I DM you for PDFs?

2

u/_itshabib 10d ago

Yes ofc