Course syllabus

This is a static page where content will remain mostly constant during the course.

See the News and Lectures page for information that is added as the course progresses.

Course design

  • The course consists of a single project: constructing a compiler for a small Java-like programming language in groups of one to two students. Groups of two are recommended.
  • To pass this course, students must pass three assignments in the Fire system, and a short oral exam during exam week. 
  • The assignments test your ability to produce a working compiler, and determine your grade for this course. Make sure that your compiler passes the testsuite before submitting. Deadlines are strict; extensions will only be granted under exceptional circumstances, and even then only if requested before the deadline in question has passed.
  • The individual oral exam tests that all group members have been actively involved in the project and share a full understanding of the compiler. You will be asked to present your compiler to the examiner, who will then ask you some questions about it. Someone else did X, I worked on Y instead is not considered a valid answer.
  • You must hand in your final assignment before being allowed to take the oral exam. No exceptions to this rule will be considered.
  • Your grade is determined by the extensions you implement in your final assignment. Your performance at the oral exam will not affect your grade other than passing or failing. 
  • There are two deadlines (D1 and D2) for each assignment. By the first deadline (D1) you must submit a reasonable attempt at a solution. By the second deadline (D1), one week after the first, you must have uploaded a full solution.
  • For the third assignment, the submission at D1 must already include all extensions that you will make part of D2. In other words, any new extensions that appear in submission for D2 that were not part of the submission for D1 will not be taken into account.

Exam

The final grading component for this course is an oral exam.

The oral exam can either be taken in-person or via Zoom. 

The exam is pass/fail. The core of the course is the project, which is difficult. The exam, which ought not be difficult, is done to check that you understand the compiler you have submitted. In particular, those that have been working in pairs should make sure that they understand all components of the compiler they have submitted.

Assignment Submission

All assignments will be submitted via Fire (link will appear here). The submission will be a single gzipped tar file, and the format required is described in detail in the documentation of the tester. The tester includes a docker image that can be used to check your submission will compile and run in our test environment.

Useful links

Lectures in EL41 at 13:15-15:00

Lectures will on campus in EDIT room EL41. See the News and Lectures page for the latest slides and demo material, and recordings of last year's lectures.

  22 March: Introduction, project overview

  25 March: Software engineering for compilers

  29 March: LLVM: tools, language

    1 April: Code generation for LLVM

    5 April: Project extensions: arrays, dynamic structures, objects

    8 April: Code generation for x86

  26 April: Control flow graphs, data analysis

  29 April: Functions

    3 May: Verified compilers

  24 May: Guest lecture

Teachers

Lecturer and examiner for the course: Magnus Myreen myreen@chalmers.se 

Teaching assistants:

Course evaluation

This course will undergo the usual course evaluation process. The student representatives for this course are: 

Learning objectives and syllabus

The official course syllabus documents: Chalmers and GU.

In short, this course teaches students about compilers and how to develop them. The course is based around a project where participants build a compiler for a small programming language called Javalette. Javalette is an imperative language, a subset of C and of Java. The finished compiler includes a frontend (lexer, parser and type-checker) and at least one backend, generating LLVM code. Optional extensions include source language extensions and a backend targetting x86 assembly.

By completing this course, students will learn concepts and techniques such as grammars, lexers, parsers, abstract syntax, type systems, syntax-directed translation and code analysis. All of these techniques are used in state-of-the-art compilers. 

Grading

To pass the course and get grade 3 (Chalmers) or G (GU), you need to:

  • submit working solutions in all submissions,
  • implement extensions worth a total of 2 credits in submission C, and
  • pass the oral exam.

 For higher grades, you need to implement further extensions in submission C:

  • for grade 4 (Chalmers), you need to earn 3 credits in submission C;
  • for grade 5 (Chalmers) or VG (GU), you need to earn 5 credits in submission C .

Your performance at the oral exam will not affect your grade other than passing or failing. The purpose of the oral exam is to check whether the code you handed in is indeed your code.

Resources: literature, software, testsuite

Books

Software tools

Many software tools are available, in particular for front ends. We give just a few links.

Common interface to all the above: BNF Converter. Flex/Bison and Alex/Happy are installed on the Linux computers in lab rooms. If you prefer to work in Java, download JLex/CUP.

Testsuite

For your and our convenience, we provide a testsuite to help verify the correctness of your compiler, in the form of a collection of Javalette test programs and a driver program that runs your compiler on these test programs. Unpack the archive in some suitable directory and follow these instructions.

Documentation for project languages

Javalette. This language only exists as source language for the project in this course, even though it is strongly similar to subsets of C and Java. See the project description. The syntax of the base language is specified by the BNFC source file Javalette.cf. You may use this as the basis for your project. On the other hand, if you already have a BNFC file for a similar language (e.g. from the Programming Language Technology course), you might prefer that, if you have supporting code for e.g. type-checking. But you must then make sure to modify it to fit the description of Javalette.

LLVM. Downloadable software, documentation and tutorials are available at the LLVM home page. In particular, you will need to consult the LLVM Language Reference Manual and the LLVM Command Guide. The LLVM tools are available on the Studat Linux machines. The input/output routines are implemented in runtime.ll.

x86 assembly language. Two books are available for free download: Paul Carter: PC Assembly tutorial and Jonathan Bartlett: Programming from the ground up. The input/output routines are implemented for 64-but x86 in runtime.s.