Compiler Construction (Summer 2025)

General Information

Lectures & Tutorials

DateTypeTopicMaterialRecordings
2025-04-22 TuLectureOrganization & IntroductionBook, Chapter 1; SlidesRec
2025-04-25 FrLectureChapter 2Book, Chapter 2; SlidesRec
2025-04-29 TuLectureChapter 3Book, Chapter 3; Slides; CodeRec
2025-05-02 FrTutorialCompiler for \(\mathcal{L}_{var}\)-Rec
2025-05-06 FrLectureChapter 4Book, Chapter 4Rec

Exercises

Exercises are provided and submitted via GitHub Classroom (follow the invite link).

Exercises will not be graded, but we will provide tests to help you verify the correctness of your work. It is highly recommended to take the exercises seriously, as the exam requires you to extend the compiler from the final sample solution with new features.

DateDeadlineTopic
2025-04-252025-05-02Compiler for \(\mathcal{L}_{var}\)

Exam

The exam will take place in the computer pools and requires you to extend the compiler implemented in the exercises with new features.

Communication

For communication outside of the lecture, we provide an discord-like chat. The chat requires you to log in with your RZ-Account (same credentials as for Ilias).

Contents

Compiler construction deals with the development and implementation of translation from higher-level programming languages to machine code. This involves several important problems of general interest:

  • Semantic Analysis. A compiler transforms and analyses the tree structure of a program. This phase is specified using attribute grammars.

  • Intermediate Code. A compiler generates machine-independent intermediate code and performs several transformation and optimization steps on it.

  • Memory model and garbage collection. The compiler maps data structures to memory structures. Languages with dynamic types and/or garbage collection require special care.

  • Machine code. Intermediate code is translated to machine code, which undergoes machine-specific optimizations. This involves techniques like tree grammars, dynamic programming and graph coloring.

Compiler construction has a long tradition, so the structure of compilers has been well thought out. Therefore, a compiler can act as an example for a well-structured software system. “Who can write a compiler, can write any program”.

Knowledge about the memory model is helpful when debugging programs written in a low-level programming language (C, C++).

Literature

This lecture is based on the Python version of the book Essentials of Compilation by Jeremy G. Siek.

We will deviate from the book in several ways:

  1. we use the (unpublished) Python version of the book;
  2. we compile to the RISC-V processor architecture instead of x86; and
  3. we use a different Python framework for the exercises.

For this reason, we maintain our own fork of the book, which is mostly ported to use RISC-V instead of x86 instructions.

Our version of the book is available on the GitHub Releases page. Simply download the book.pdf file for the most recent release.

To get notified on new releases, we recommend the watch-button on the book’s GitHub repository, select Custom in the dropdown menu, and select Releases.

Additional Literature

  • Andrew Appel with Jens Palsberg, Modern Compiler Implementation in Java, 2nd edition. Cambridge University Press, 2002
  • Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman. Compilers, Principles, Techniques, and Tools (2nd Edition).. Prentice Hall, 2006.
  • Andrew W. Appel. Compiling with Continuations. Cambridge University Press, 1992.
  • Andrew W. Appel. Modern Compiler Implementation in ML. Cambridge University Press, 1998.
  • Christopher W. Fraser and David R. Hanson. A Retargetable C Compiler: Design and Implementation. Benjamin/Cummings, 1995.
  • Reinhard Wilhelm and Dieter Maurer. Übersetzerbau – Theorie, Konstruktion, Generierung – 2. Auflage. Lehrbuch. Springer-Verlag, Berlin, Heidelberg, 1996.