r/programming • u/shortstomp • Nov 19 '16
Compile-time C Compiler implemented as C++14 constant expressions
/r/cpp/comments/5dnan4/compiletime_c_compiler_implemented_as_c14/51
u/unaligned_access Nov 19 '16
Yo dawg I heard you like compiling so we put a constexpr compiler in your compiler so you could compile while you compile...
8
u/badsectoracula Nov 19 '16
The interesting bit (judging from the code) is that the constexpr is actually a VM and the compiler is the bytecode it executes :-P
6
u/Fazer2 Nov 19 '16
From readme:
How was constexpr-8cc generated?
When you see 8cc.hpp, you will know this program was not written by hand. Actually, I used ELVM Compiler Infrastructure to generate it. I just implemented a translator from ELVM IR to C++14 constexpr here.
4
u/WalterBright Nov 19 '16
Reminds me of the time someone wrote a Fortran compiler in TECO (on a bet!).
2
1
-1
30
u/PointyOintment Nov 19 '16
Is a compile-time compiler a compiler that operates only while being compiled by another compiler?