4 ms·
The code is very easy to read, so I think this would be great for those who want to learn how one might go about implementing a C compiler.
by rikkus 12y ago
The code is very easy to read, so I think this would be great for those who want to learn how one might go about implementing a C compiler.
- andrewchambers 12y agoI personally struggled to work with other compilers, I think TCC is too terse, and GCC/Clang have too much code. https://github.com/rui314/8cc https://github.com/rui314/8cc Got things right, and I am trying continue with it's style. I will be happy if a student can take my compiler and port it to his own invented cpu with a modest amount of work.
- userbinator 12y agoTerseness is quite a subjective thing, as I think TCC is not all that small among all the C (and C-subset) compilers that exist like Small-C; on the other hand, OTCC is in realm of "too terse" for me. This one is more agreeable with my style (and I think the parser in it is amazingly concise and elegant): https://github.com/rswier/c4/blob/master/c4.c https://github.com/rswier/c4/blob/master/c4.c
- andrewchambers 12y agoTCC packs a C compiler, assembler and linker together, So it has a large amount of functionality, even if it is no longer so tiny. The code style is really dense too. Frequently using single letter function and variable names. e.g. Outputting data into the final data segments uses functions named o() and o32().