[OT?] C compiler written form scratch in D

Shachar Shemesh via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Dec 11 06:59:44 PST 2014


On 09/12/14 02:45, deadalnix wrote:
> On Monday, 8 December 2014 at 15:44:55 UTC, Stefan Koch wrote:
>> I want to do a C backend first.
>> Building an LLVM Backand out of that is a small step.
>
> There is already a very popular C to C compiler out there. It is
> called cat, and come out of the box with any UNIX like system.

I know it was meant as a joke, but I couldn't resist nitpicking.

When Stroustrup started out with an OO successor to C, he wrote a 
preprocessor that would convert his new syntax to C, to be passed to a C 
compiler. When the language started to evolve, that proved insufficient, 
and he wrote CFront, a C++ to C compiler.

He defines the difference between a preprocessor and a compiler along 
these lines: With a compiler, any and all compilation errors need to be 
caught by the front end. If the front end accepted your program, and the 
back end fails to compile it, it is, by definition, a compiler bug.

As such, cat (nor its close neighbor, "tac | tac"), are not a compiler, 
since it does not catch compilation errors.

Sorry for the nitpick.
Shachar


More information about the Digitalmars-d-announce mailing list