2 ms·
Better off making it close to but not C language so it's easy to compile. A language easy to compile + easy to write a compiler in. Scheme and ML are probably i
by nickpsecurity 10y ago
Better off making it close to but not C language so it's easy to compile. A language easy to compile + easy to write a compiler in. Scheme and ML are probably ideal for the compiler + verification part given I've seen it done already down to machine code in relatively few pages of text. Not C-like, though.
Best method I can think of is assembly writes a macro assembler that writes compiler for simple, high-level language which is used for the first, C compiler. That compiles the complicated, optimizing one. HLA, a P-code variant, and Hansen's Edison are all potential contenders for low-level language. An Oberon-like language with something closer to C syntax & Wirth-style compiler might do for initial, high-level language. tcc or QBE backend have potential for simple, initial, C compiler. I'd do both LLVM and GCC for last step as good projects rely on each.
If one wanted to spend money, then license CompCert, extract it to ML, compile with CakeML, verify each function against assembly, and equivalence check everything with testing. CompCert verifies C to ASM with its outputed ML verified by CakeML assuming their specs are correct. Easiest cheat. Use CompCert to compile first C compiler, the main C compilers, or anything else you can.