Spring, 2016
Me:
|
Office Hours:
|
Course Description:
This is a course on the theory and implementation of compilers. There are 5 big parts to any compiler:
- lexical analysis, which splits the source program into its words,
- syntactic analysis, which uses a grammar to identify the functional parts fo the course program,
- semantic analysis, which does type checking and other analysis of aspects of the source program that are not subject to the grammar
- code generation, which produces code in the target language, usually an assembly language
- optimization, which improves the quality of the generated code
We will write modules to cover at least the first four of these activities to compile a language I call BPL into 64-bit Intel assembly language. BPL is a dialect of C with the usual control structures and recursive function calls, but only integers, llimited strings and pointers, and arrays as its data structures. The data structures that we will not implement are time-consuming but not difficult or particularly interesting to implement. We will discuss in class the alternatives for each of the compiler modules though I will recommend at each step that you use the simplest, most direct approach for your implementation. At the end of the semester you should have a full, working, but probably not very efficient, compiler for BPL.
Textbook:
Engineering a Compiler by Cooper and Torczon
I won't follow this chapter by chapter, but there are places where you will want a reference for the course. This seems to me to be the most readable of the half-dozen Compiler books currently available.
Grading
The project for this class is very large; each module requires the previous modules to all be working correctly. To avoid having a high failure rate, I am going to try something new. There are two ways you can take this course -- as a project class or as a theory class. I strongly prefer that you do the project. However, if you get lost in the project, there will be an optional midterm and final; if you take both of those and do well on them you will pass the course regardless of the state of your project. Here are the grading schemes for the two versions of the course:
Project Version:
All 4 modules working: A
Project working through Type Checking, some progress on Code Generation: B
Project working through Parsing, Type Checking mostly working: CExam Version
Good job on miterm and final: B
Adequate job on midterm and final: CNote two things:
- You cannot get a grade above a B for the class without doing to the project.
- The midterm will be right before Spring Break. By that time you should have two modules completed and a fair start on the Type Checker. You should have enough done to pass the course before you need to decide if you should take the midterm. If your project isn't going well, you should definitely take the exam. If your project is going well, you won't need to complete that much more of it to earn the highest grade you could achieve through the exams.
There will also be opportunities toward the end of the semester for students to make presentations on optimization techniques, alternative language features, and other issues. We'll discuss this in class after we see how the project develops.
The Honor Code
The Honor Code has a straightforward application to this class. You may discuss the programming projects with anyone else and use any outside sources you want, but in the end you need to write all of your code yourself. The exams will be closed-book exams taken in class, and you obviously should not receive help from anyone during these exams.
This is a rough outline, which I probably won't stick to. It should give you at least an idea of what we will be doing in the course. The due dates are all subject to change as I see how quickly you are able to complete the modules.
1. Introduction -- First Day
2. Lexical analysis -- scanning. 1 week
Scanner Module due on Friday, Feb. 12
3. Grammars and syntactical analysis. 3 weeks
Parser Module due on Monday, March 7
4. Type checking and semantic analysis. 3 weeks
Type Checker due on Monday, April 4
5. x86-64 Assembly Language
6. Code generation
Code Generator due the last day of classes: Friday, May 6
7. Optimization
For those taking the exams, here are there dates:
Optional midterm exam: Wednesday March 16
Optional final exam: Thursday, May 12, 7pm