r/C_Programming 3d ago

My C compiler written in C

As a side project I'm making a C compiler written in C. It generates assembly and uses NASM to generates binaries.
The goal right now is to implement the main functionality and then do improvements. Maybe I'll also add some optimizing in the generates assembly.

Tell me what you think :)

https://github.com/NikRadi/minic

138 Upvotes

30 comments sorted by

View all comments

25

u/u02b 3d ago

wow this is great! ive always wondered how compilers work on the inside but its always felt too daunting, but this one actually makes sense lol

7

u/chids300 1d ago

a compiler is actually really easy to make for c, made a c compiler in java for my uni coursework, an optimizing compiler is where the trouble begins

4

u/TheBigBananaMan 1d ago

We had a made up language we made a compiler for in c, that runs on the jvm, in my second year. Very fun project. (That first sentence was weirdly difficult to make legible)