TDDB44 Compiler Construction
The laboratory exercises are performed in groups of two students, 8 groups per Sun-laboratory. Last date for sign up is 15/11 - 2013. The lab material is quite extensive and will not be presented on these web pages. See the course literature section on the start page.
To be able to solve the laboratory assignments on time you must be well prepared for every laboratory exercise. Past experience has shown that the amount of work involved is often underestimated.
There are 7 separate parts of the compiler to complete in 11x2 hours in the computer laboratories.
The Laboratory Compendium
The TDDB44 Laboratory compendium is available at Bokakademin.
The aim of this laboratory assignment is to implement a compiler for a simple imperative language (DIESEL) in C++, using modern tools to help generate parts of the code. The work is estimated to take about 80 hours (based on statistics from 1998). The compiler is to be written in the following order and to comprise the following parts:
- Scanner - manages lexical analysis.
- Symtab - administrates the symbol table.
- Parser - manages syntactic analysis, builds internal form.
- Semantics - checks static sematics.
- Optimizer - optimizes the internal form.
- Quadruples - generates quadruples from the internal form.
- Codegen - expands quadruples to assembler.
The parser, semantic, quads and codegen parts are the ones likely to take the most time, so try to get the scanner and symbol table labs done the first week. Skeleton code will be provided for all the labs, and in most cases you will simply keep on adding code to what you wrote in the previous lab. The skeleton contains declarations of central data-structures and support routines; in other words, a lot of the boring work has already been done for you. The aim is to let you concentrate on the essential details.
xxgdb can be recommended for fault-finding; it is window-based and very useful. There are other debuggers available as well.
This compendium starts by describing DIESEL 4.0 in the way it would be presented to a fictitious user. Then an overview of the compiler follows which hopefully gives an idea of what the various phases do. After this come the various parts of the lab work, where each phase is described in a section of its own. These are usually introduced by some theory from the lectures, which it is generally a good idea to read up on before starting the lab work. When a phase has been completed and tested, report to the assistant and then continue with the next one.
The deadline for the labs is the end of the lecture period 20/12 - 2013.
While it will still be possible to submit your lab report to your lab assistant afterwards, we then cannot guarantee that your lab points will be counted as a 2013 result, as we have to prioritize the correction of the exam.
Page responsible: Martin Sjölund
Last updated: 2014-08-26