

As I already mentioned last time, the Data structures are important and will be needed after we get into Symbol Tables and so check them out if you don't know them yet! The good thing is that I did a lot of posts in C and because the tools Flex and Bison also use C we will get even more into C programming now! You can check out my C posts in the recap here. This means that we will write a compiler for C in C But the problem is that C has some complicated behaviors that will take us months to write and so we will simplify the language to get an easier/simple C.

I thought a little bit about the language that we should write the compiler for, and got to the conclusion that C should be just fine.

Hello it's a me again Drifter Programming! Today we continue with my simple compiler project. You should also follow me on Twitter here. Even if nobody else could actually understand what it was doing or why. So I’ve always had a soft spot in my heart for Haskell. It’s the one piece of code that I look back on and wish that I still had a copy of. Just a real work of art, with the data flowing through the code in one of the most natural ways I’ve ever seen. It was, without a doubt, one of the most beautiful programs that I’ve ever written. I somehow managed to grok enough of Haskell to be able to write a functioning compiler that took our toy language in and produced correct output. Definitely honed the skill of “psychic debugging.”Īnyway, with a brand-new language (that, of course, had no manuals or books written about it yet) and an alpha-level (at best) compiler, as I remember it at least half the class never even managed to get something working. I think the Haskell interpreter was written in Common LISP, and basically you took your program, invoked the interpreter on it, went and got yourself a nice cup of tea (so to speak), and then came back to an answer (if you were lucky), an undecipherable error message (if you were only kind of unlucky), or just nothing (most of the time). According to Wikipedia, Haskell debuted in 1990, so first and foremost the tools we were working with were… uh, primitive at best. The thing is, this class took place probably in the fall of 1990 or the spring of 1991. The twist was, that the professor for this class happened to be one of the designers of the Haskell language, so you can guess what programming language the compilers had to be written in. The main project for the class, of course, is to build a compiler for a small language. In my junior year of college, I took the standard programming languages course that goes over fun stuff like how programming languages are put together. In the useless memories department, xkcd’s cartoon today took me back:
