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.
- 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.
The final grading component for this course is an oral exam.
This will be conducted online 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.
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.
- The github repo with the project description, the tester and other resources.
- The resource section has links to literature and software tools.
- The Fire webpage is where assignments are to be submitted.
- The discussion forum is a place to discuss topics related to the course.
- The TimeEdit schedule of the lectures.
- The website of the 2020 iteration of TDA283 is also online.
Lectures online at 13:15-15:00
Lectures will be delivered via Zoom and recorded. See the News and Lectures page for Zoom links and recordings.
23 March: Introduction, project overview
26 March: Software engineering for compilers
30 March: LLVM: tools, language
31 March: Code generation for LLVM
13 April: Project extensions: arrays, dynamic structures, objects
16 April: Code generation for x86
27 April: Control flow graphs, data analysis
4 May: Functions
7 May: Verified compilers
25 May: Guest lecture
Lecturer and examiner for the course: Magnus Myreen email@example.com
Teaching assistant: Oskar Abrahamsson firstname.lastname@example.org
This course will undergo the usual course evaluation process. The student representatives for this course are Soundarya J, Daniel Willim, Daniel Stribrand, and Lukas Skystedt.
Learning objectives and syllabus
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.
To pass the course and get grade 3 (Chalmers) or G (GU), you need to:
- submit working solutions in all submissions,
- implement at least one language extension in submission C, and
- pass the oral exam.
For higher grades, you need to implement optional 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 .
Resources: literature, software, testsuite
- The text book for the course is Aho, Lam, Sethi and Ullman: Compilers: Principles, Techniques, and Tools, 2nd. ed (Pearson International Edition 2007). Available at Cremona and several web stores.
- An excellent text book on modern compiling techniques is Cooper and Torczon: Engineering a Compiler. Focuses on backend issues; careful choice of material and very well written.
- A somewhat dated but nice book on implementing lazy functional languages is Peyton-Jones and Lester: Implementing functional languages (free download as PDF file).
Many software tools are available, in particular for front ends. We give just a few links.
- For C programmers: Flex and Bison.
- For Java programmers: JLex and CUP.
- For Haskell programmers: Alex and Happy.
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.
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.
The syllabus page shows a table-oriented view of course schedule and basics of course grading. You can add any other comments, notes or thoughts you have about the course structure, course policies or anything else.
To add some comments, click the 'Edit' link at the top.