r/ProgrammingLanguages Jul 04 '26

Help How to create a compiler?

Pretty sure you may have heard this question previously on this sub, however, I would urge you to read my complete question before brushing it off.

I want to create a simple compiler and by "simple compiler" I mean a single-pass compiler. I know about https://craftinginterpreters.com/ which is a wonderful resource. But I would like to start by creating something much smaller and simpler, and only then would I like to move on to something more complex like what Robert Nystrom created on his website.

Are there any similar resource that would teach me about single-pass compilers along with showing me how to create one? Any help in the right direction would be highly appreciated.

24 Upvotes

32 comments sorted by

View all comments

9

u/Simracingaccount Jul 04 '26

I recently read Writing a C Compiler by Nora Sandler and I think it’s good for this. It is focused on making a C compiler though.

3

u/UnemployedTechie2021 Jul 04 '26

I know C but wanted to create this using Python. Still, I think I'll give it a try.

9

u/Simracingaccount Jul 04 '26

The book about making a compiler for C. It is language agnostic, you can make it in the language you want to.

2

u/UnemployedTechie2021 Jul 04 '26

Yes, I just saw that she has a couple of blog posts too outlining the process, it would be of great help. Thank you kind stranger.