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, 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. The final deadline before the oral exams is strict. The other deadlines are only there to encourage a good pace of study in this course.
  • 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. 
  • Submissions are made in the gitlab system, see description below. 

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

You will develop your code in Chalmers gitlab and make submissions in gitlab by tagging commits as submissions. See instructions on gitlab and how to make submissions.

Deadlines

We expect submissions according to the dates shown below. The first three deadlines are soft deadlines that indicate expected study pace. However, the Extensions final deadline is strict. We will not accept any submission after 28 May 2023, so make sure to submit a first version for the Extensions first deadline 21 May 2023.

  • Frontend deadline:  Wednesday 29 March 2023
  • Backend deadline:  Wednesday 19 April 2023
  • Extensions first deadline:  Sunday 21 May 2023
  • Extensions final deadline:  Sunday 28 May 2023

Slack

This course uses Slack as a quick communication medium. Use it to ask questions about the course, gitlab, find a project partner, etc. Follow this link to join Slack.

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 past lectures.

  21 March: Introduction, project overview

  24 March: Software engineering for compilers

  28 March: LLVM: tools, language

  30 March: Code generation for LLVM

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

  21 April: Code generation for x86

  25 April: Control flow graphs, data analysis

  28 April: Functions

    2 May: Verified compilers

    9 May: Research talk at 11am in EDIT Analysen

Teachers

Lecturer and examiner for the course: Krasimir Angelov krasimir@chalmers.se

Teaching assistant (TA): Oskar Eriksson oskeri@chalmers.se 

Course evaluation

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

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. 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.