Often great effort is put into optimizers to make the produced code blazing fast with various clever tricks like constant folding, loop unrolling and dead code elimination. Furthermore, it lacks a code optimizer module, which is actually the biggest part of modern compilers. The full source code of the compiler implementation discussed in this blog post can be found from github.Īs will become apparent shortly it is not a full implementation of the C language nor is it a full standalone compiler (actually only the Front-End of a compiler, to be precise) either. Many pictures and examples are given as a serious attempt to make the task of the reader at least somewhat bearable. It means I should also more or less know what I’m talking about, right.? Well, we’ll see… Furthermore, references for the interested readers are provided for reading all about the mindboggling details. Yes indeed, I wrote a compiler myself, I’m not just all talk and no action after all. That said, this tutorial gives you a high level overview of the process and key concepts with the complete source code attached. But don’t worry, this blog post probably discusses more topics than you’re willing to read anyway. That would deserve its own text book… Oh wait, there is exactly such a thing! If you’re interested more on the topic, check out the Dragon book after reading this blog post. In addition, this is by no means a complete guide on how to write your own compiler. However, I have to start out with a disclaimer that this blog post expects some familiarity with common programming concepts such as data structures and recursion. Have you ever wondered what black magic happens when you click “Compile” in your editor and your source code magically turns into an executable binary? Do you want to know what lies at the very heart of all programming? Are you not afraid of the challenge of implementing this mysterious mechanism yourself? Do you think you could use a couple of good coding practices as well? If you answered yes to any of these questions, then this blog post is just for you! “In college, before video games, we would amuse ourselves by posing programming exercises.”
0 Comments
Leave a Reply. |