Compilers; final projects
Spring Semester 2005 and 2006
  Winter Style | Home » Old » School Projects » Compilers
 
 

(Compiler Construction, Spring Semester 2005) This was flat-out one of the most challenging classes — and therefore one of the most interesting — that I have had the pleasure of taking (thanks in no small part to an excellent professor). Unfortunately, it happened to coincide with a very different project, which lead to a final product that was, shall we say, “below expectation” ;)

The goal of the course was to create a compiler in C to compile a subset of the ADA/CS programming language into JVM bytecode. With the help of tools like flex and bison (though personally I would have preferred to learn about ANTLR), we took on a different segment of the project (lexer, parser, compiler) every few weeks.

However, as the semester began drawing to a close, I (along with about half of the class) began to face a common problem: a lot of work left to do, and not enough time to do it in (what with studying for finals and/or other final projects). In the end, the assignment was simplified from creating a full-fledged compiler for ADA/CS to supporting a few basic constructs (i.e. constants, loops, variables, variable initialization, variable assignments, etc, etc). All of the stubs for a full-fledged compiler are still in my implementation, but don’t expect the code generator to recognize them ;)

My greatest problem with the project, though? I do not like C. It is just a nasty language to work in because, on top of the compiler logic itself (which was fairly straigt forward), I had to be very, very careful about how I handled memory. Out of the thousands of lines of code in the project, I believe there were only two memory errors (both of which involved freeing the same bit of memory twice), but that number is so low only because I spent at least half of my time checking and double checking my work*. A reflection of poor design? Perhaps. But, then again, what design tools do I have to work with? Well, lets see: there are functions, and structs, and . . . that’s it!

Yeah, yeah; excuses, excuses :) The root of the problem is probably just a clash of styles. I didn’t grow up with C’s style of programming, or with the concept of files as modules. That’s simply not the way I think (which probably says more about me than the language ;).

So, am I totally fed up with compilers now? Heck no! Lets face it: languages are just plain cool :) Hopefully, at some point in the future, I’ll have the time to work on them again ;D

 

(Graduate Compilers, Spring Semester 2006) Being a glutton for punishment, I jumped at the opportunity to take another compilers class ;) And, while I learned much about the nitty-gritty details of compiler implementation and low-level code analysis, I’d say overall the class was not all that captivating.

As I mentioned above, much of my interest in compilers derives from my fascination with languages (computer and otherwise).For example, talking about temporary variables, register coloring, liveness analysis, and such when covering registry allocation was, while interesting from a technical standpoint, does not capture the imagination as well as turning loops into bytecodes did :)

Now I will admit that my recollection is a bit hazy, having been a bit over a year since I took the class (hence my rather vague tone).Still, reviewing the assignments and final project, it all comes back pretty quick ;)

Speaking of which, the final project I ended up working on dealt with implementing a points-to alias analysis algorithm on top of the computer science department’s C-Breeze C compiler that we had been working with through the semester. The Pearce algorithm I was charged with took a while to wrap my head around, but after getting a handle on how it worked it became pretty easy to translate into C++. Of course, you can read about all the exciting details in the download (psst, the details aren’t actually very exciting ;). Personally, I think I’ll stick with languages ^^

 

 

* – I’m not saying that checking your work is bad, just that I’d rather spend half my time checking the program’s logic and let the compiler/environment/whatever handle what to remember ;) 

 
 
Go back a page |  Ada Compiler,  Source Code |  Ponter Analysis,  Source Code | Resume Entry | @ | Copyright © 2005-2011 Paul A Hansen. Some rights reserved.