Welcome to the course in Compilers and Execution Environments!
In this course, you will learn how a compiler works. You will learn about compiler theory, for instance regular expressions, parsing theory, optimization algorithms, code generation strategies, garbage collection, and more. Moreover, you will gain significant practical experience in designing and implementing a complete compiler from scratch. You will develop a compiler for a rather small language called Cigrid, which is a subset of C/C++, specifically designed for teaching. Your compiler will compile into x86 assembly code, such that you can benchmark your optimization strategies against a state-of-the-art compiler, such as GCC or Clang.
The course is given each fall during period 2 (October to December).
For details, please see the course homepage:
Choose semester and course offering
Choose semester and course offering to see information from the correct course syllabus and course offering.
Content and learning outcomes
The course covers technologies for implementation of programming languages by means of compilers, both for real and virtual execution environments, technologies to read, understand, translate, improve as well as execute programs:
- To read programs: lexical analysis and syntax analysis. Finite state machines, regular expression context free grammars, LL and LR-parsing.
- To understand programs: semantic analysis, type checking.
- To translate programs: machines and instructions.
- Intermediary code, choice of instructions, conventions for procedure calls.
- To improve programs: machine independent optimisations; computer-oriented optimisations (register allocation, scheduling of instructions).
- To execute programs: virtual execution environments and runtime systems. Memory management, garbage collection, to load and link programs, just-in-time compilation.
Intended learning outcomes
After passing the course, the student shall be able to
- use methods for lexical, syntactic and semantic analysis
- use methods for generation of machine code
- use methods for optimizing programs
- give an account of common components in execution environments
in order to
- obtain an understanding of how a programming language is implemented as well as for the general theories that are used and how these can be applied.
For higher grades, the student should design more complex components of a compiler. The details are specified in the course memo.
Literature and preparations
Knowledge in basic computer engineering/architecture, 7.5 higher education credits, equivalent to completed course IS1200/IS1500.
Knowledge in algorithms and data structures, 7.5 higher education credits, equivalent to completed course ID1020/ID1021.
Active participation in a course offering where the final examination is not yet reported in LADOK is considered equivalent to completion of the course. Registering for a course is counted as active participation. The term 'final examination' encompasses both the regular examination and the first re-examination.
Very good programming experience in one or more high-level languages.
ID1019 Programming II or corresponding course.
Information on course literature is given in the course PM.
Examination and completion
If the course is discontinued, students may request to be examined during the following two academic years.
- DAT1 - Computer based exam, 7.5 credits, grading scale: A, B, C, D, E, FX, F
Based on recommendation from KTH’s coordinator for disabilities, the examiner will decide how to adapt an examination for students with documented disability.
The examiner may apply another examination format when re-examining individual students.
Opportunity to complete the requirements via supplementary examination
Opportunity to raise an approved grade via renewed examination
- All members of a group are responsible for the group's work.
- In any assessment, every student shall honestly disclose any help received and sources used.
- In an oral assessment, every student shall be able to present and answer questions about the entire assignment and solution.
Further information about the course can be found on the Course web at the link below. Information on the Course web will later be moved to this site.Course web ID2202
Main field of study
For students who have been registered in the course during autumn term 2019 or earlier and have either TEN1 or INL1 reported in the National Student Record Base (LADOK) are offered oral examination of the other course component (either TEN1 or INL1) up until and including the spring term 2021. If the student wants such an examination, they must contact the examiner via email latest final May 2021. Oral examination is not offered for students who have been registered in the course during 2019 or earlier, and who do not have any of the items reported in the National Student Record Base (LADOK).
In this course, the EECS code of honor applies, see: http://www.kth.se/en/eecs/utbildning/hederskodex.