Programming Language Technology

DAT151 (Chalmers) / DIT231 (GU)
Winter Term 2019 (LP2)

http://www.cse.chalmers.se/edu/course/DAT151/

Fire / Canvas / Chalmers studieportal / GU ad / GU kursplan / GU course description / Course page 2018

News and changes

2020-08-17
The second reexam will be held 27 August on Canvas organized as course 12065. If you registered to the exam, you should have gotten an invitation to this course. Please read the instructions there.
2020-04-05
The reexam will be held 7 April on Canvas organized as course 9969. If you registered to the exam, you should have gotten an invitation to this course. Please read the instructions there.
2020-01-25
The deadline for all labs has been extended to 10th February.

2020-01-21
Exam review will be Wed 29 January 10am in EDIT 5128. Exam text and solution.

Deadline extension: Lab 4 submission on Fire is now possible until the final deadline (23rd Jan).
2019-12-18
In the last lecture, we will walk through an example exam.

2019-12-18
The live code for "hands on lab4" contains too much of the solution, thus, will not be published. See the PLT book chapter 7.6 and this Canvas post for advice on the implementation.

2019-12-17
Live coding in Agda start and finish on verified compilation.
2019-12-12
A bug that caused some test (e.g. the tests in the subtyping directory) to not run has been fixed in the lab 3 test suite. Please re-download the test suite.

2019-12-12
Lab 4 is online.
2019-12-03
The test suite for lab 3 now includes a good/subtyping directory that contains tests for handling subtyping correctly.

The code from today's "Hands-on for lab 3" session is online (Haskell and Java). (Note: should compile, but does not run!)

2019-11-29
Lab 3 is online.

2019-11-26
The code from today's "Hands-on for lab 2" session is online (Haskell and Java).
2019-11-22
For lab2, we clarified in the lab text that there is no need to type annotate the code during type checking. Annotations will become relevant first in lab3. We also added test cases for error reporting of unused variables (see the directory bad-runtime).

2019-11-14
The parse table on page 53 of the plt book is incomplete, missing the goto actions. See instead a happy generated LR parse table for this LBNF grammar.
2019-11-07
MiniJS implementation in Haskell and Java.

2019-11-02
First published version of this page. Lab 1 and Lab 2 descriptions online.

Labs are done in groups of 2. Please look for a lab partner.

Tentative Schedule

Tuesday lectures are in HC2, Thursday lectures in HA1, starting at 13:15.

Material: plt = course book, dragon = Dragon book. Slides follow closely the plt book.

Date Time Title Material
Tue 05/11 13-15 PL Design, Compilation Phases, MiniJS slides, plt 1, dragon 1, live coding start lecture finish
Thu 07/11 13-15 Grammars / BNFC / Hands-on with Lab 1 slides, plt 2, dragon 2.8.2,4.1-4.3
Tue 12/11 13-15 Formal languages and parsing LR parse table for grammar
Thu 14/11 13-15 Theory of lexing slides, plt 3, dragon 3,4
Mon 18/11 23 Lab 1 deadline lab1 PM
Tue 19/11 13-15 Interpreting slides, plt 5
Thu 21/11 13-15 Type checking slides, plt 4, dragon 5,6
Tue 26/11 13-14 Hands-on with Lab 2 (Haskell) lab2 PM Monads
Tue 26/11 14-15 Hands-on with Lab 2 (Java) live coding
Thu 28/11 13-15 Code generation slides, plt 6, dragon 6,7
Mon 02/12 23 Lab 2 deadline
Tue 03/12 13-14 Hands-on with Lab 3 (Haskell) lab3 PM
Tue 03/12 14-15 Hands-on with Lab 3 (Java) live coding
Thu 05/12 13-15 Functional programming languages slides, plt 7, dragon 6.5,7.3
Tue 10/12 13-15 Type inference and polymorphism plt 7.7-9
Thu 12/12 13-15 Hands-on with Lab 4 lab4 PM
Mon 16/12 23 Lab 3 deadline
Tue 17/12 13-15 Dependent types (Agda) Live coding start and finish
Thu 19/12 13-15 Preparing for the exam Training Exam
2020
Thu 09/01 23 Lab 4 deadline
Mon 13/01 8.30-12.30 Exam (J)
Thu 23/01 23 Final lab deadline all lab returns
Wed 29/01 10-11.30 Exam review (EDIT 5128) Solution
Tue 07/04 8.30-12.30 Exam (Canvas)
Thu 27/08 14-18 Exam (Canvas)

The official course schema is in Time Edit.

Description

The aim of the course is to give understanding of how programming languages are designed, documented, and implemented. The course covers the basic techniques and tools needed to write interpreters, and gives a summary introduction to compilation as well. Those who have passed the course should be able to

  1. define the lexical structure of programming languages by using regular expressions, explain the functioning of finite automata, and implement lexical analysers by using standard tools;
  2. define the syntax of programming languages by using context-free grammars, explain the principles of LL and LR parsing, and implement parsers by using standard tools;
  3. define and implement abstract syntax;
  4. master the technique of syntax-directed translation and its efficient implementation in their chosen programming language;
  5. formulate typing rules and implement type checkers;
  6. formulate operational semantic rules and implement interpreters;
  7. write simple code generators;
  8. be familiar with the basic implementation issues of both imperative and functional languages;
  9. master the principles of polymorphic type checking by unification;
  10. implement an interpreter for a functional language.

Teachers

Andreas Abel, responsible course teacher and examiner.

Mohammad Ahmadpanah (MA), Andreas Lööw (AL), Fabian Ruch (FR), assistants.

Questions regarding this class (organization, content, labs) should be asked publicly on the Canvas forum in the most cases. You are also welcome to answer questions by others. (Don't give away any lab solutions when you ask or answer questions!)

Laboration times and supervision

Lab supervision take place in ED3354.

Day Time Supervisors
Tue 15:15-17:00 FR MA
Thu 15:15-17:00 AL MA
Fri 13:15-15:00 AL FR

The lab rooms and supervision are available from Thu 07 November till Fri 20 December 2019.

Attendance in these classes is optional. Normally, each student should attend at most one supervised laboration time each week. Since attendance is not compulsory, there may be room for more times. But, if there is lack of room, those who attend their first supervision of the week have priority to get a place and supervisor help.

Laborations

There will be four laborations, written in pairs. (Individual solutions are accepted per exception, please contact the course responsible.) You have to pass the labs to pass the course. However, the course grade is determined solely by the exam.

The labs are quite substantial, so please set aside at least 30 full working hours (4 full working days) before the deadline. It is recommended to start at least 10 days before the deadline.

It is recommended to use a version control system like git for code development. In case you use cloud-based code hosting like e.g. github or bitbucket, make sure your repository is private to not give away your lab solution. (Along the same lines, never post your solution on public fora and mailing lists!)

Reporting is done via Fire. Before submitting your solution, run your program through the provided test suite. Also, make sure that your submission contains all necessary files and the build succeeds. For instance, if you are submitting an archive, unpack the archive in a fresh directory and check the build there.

We guarantee two gradings per lab: one for the version submitted before the ordinary deadline for that lab, the other for a resubmission before the final deadline. If your first submission does not build or does not pass the testsuite, you will just get fails testsuite as grading.

Note: You have to submit something by the first deadline, otherwise Fire will not allow a (re)submission for the final deadline. (In the worst case, if you absolutely did not manage to work on the lab before the first deadline, submit an empty solution.)

As part of the grading, you may be asked to explain your solution in person to a course teacher. Be prepared to get a call for such an explanation meeting. In particular, make sure you understand all parts of the solution (good documentation helps!).

Exam

The written exam determines the course grade, the usual grading scales apply: Chalmers: 5, 4, 3, U; Gothenburg University: VG, G, U.

Exam dates: 13 Jan 2020 am J, 07 Apr 2020 am J, 27 Aug 2020 pm J.

The exam tests the understanding of the course contents from a more high-level view, e.g., the underlying theoretical concepts. The exam has the same structure as these old exams (download as archive).

Further, here are some exercises and solutions to prepare for the exam.

Literature

The main book will be one that developed from earlier editions of this course:

Aarne Ranta
Implementing Programming Languages. An Introduction to Compilers and Interpreters, College Publications, London, 2012. Web page (with extra material and links to selling sites)

Errata

If you are really interested in the topic, for instance, if you want to continue with the Compiler Construction course, you should also consider the Dragon book,

Aho, Lam, Sethi & Ullman
Compilers Principles, Techniques & Tools, Second edition, Pearson/Addison Wesley 2007.

Both books are available at web bookshops. The main book will also be sold at Cremona.

A good (yet slightly dated) introduction to monads in Haskell, useful for implementing interpreters, type checkers, and compilers, is this article:

Philip Wadler
Monads for functional programming. In Advanced Functional Programming, First International Spring School on Advanced Functional Programming Techniques, Båstad, Sweden, May 24-30, 1995.

It also contains an introduction to parser combinators.

Software

BNF Converter 2.8 http://bnfc.digitalgrammars.com/ | Hackage | github

You can compile the latest version of BNFC (2.8.3) from its Haskell sources via

    cabal update
    cabal install BNFC

You might find a suitable binary distribution for an older version of BNFC (2.8).

If using the Java backend, you will need the CUP and JLex libraries. CUP has seen incompatible changes in its interface; thus, the version you need may depend on your BNFC version.

Instructions for BNFC 2.8.2/3 (uses CUP v0.11b)

Download the JAVA archives for CUP v11b, CUP v11b runtime, and JLex, contained in javatools. Make sure they are placed in your classpath, for example (Linux / MAC OS) by storing these jars in $HOME/java-lib/ and adding the following to .bashrc (single line):

    export CLASSPATH=.:${HOME}/java-lib/java-cup-11b.jar:${HOME}/java-lib/java-cup-11b-runtime.jar:${HOME}/java-lib/javatools.jar:${CLASSPATH}

The order matters since javatools.jar also contains an older version of CUP; make sure that javatools.jar comes last in the search path.

Instructions for BNFC ≤ 2.8.1 (uses CUP v0.10k)

You can download pre-compiled versions here. Make sure they are placed in your classpath, for example (Linux / MAC OS) by extracting to ~/javatools/ adding the following to .bashrc:

    export CLASSPATH=.:~/javatools/:~/javatools/Cup/:${CLASSPATH}

On Debian-style Linux (like Ubuntu), the following now also works to install these libaries:

    sudo apt install jlex cup

Then the class path needs to be set as follows (bash):

    export CLASSPATH=.:/usr/share/java/JLex.jar:/usr/share/java/cup.jar

Student representatives

Student representatives for DAT151 Programming language technology.

Program @student.chalmers.se Name
MPALG kokkou Maria Kokkou
TKDAT ljerik Erik Ljungdahl
MPCSN marlofg Martin Löfgren