Principles of Programming Languages [PLP-14]

Code 603AA - 9 Credits


LECTURER Andrea Corradini <andrea@di.unipi.it>
Timetable (second semester) Tuesday 9-11, Room Fib L1
Friday 11-13, Room Fib A1
Office hours Click here

Announcements


Evaluation criteria

The final grade is based on a written exam (possibly substituted by two mid-term exams) and on an oral proof.

Information for students enrolled before Academic Year 2014/15

Students enrolled in A.Y. 2013/14 or before have, in their study plan, the course "Principles of Programming Languages - Code 379AA - 12 Credits", taught in the past years by Prof. Marco Bellia. They can either The current course started in November 2014 and will run till May 2015. Students intending to take the exam in the summer session are strongly invited to attend the rest of the course.

Textbooks

  1. [ALSU] Compilers: Principles, Techniques, and Tools
    by Alfred V. Aho, Monica S. Lam, Ravi Sethi, and Jeffrey D. Ullman, 2nd edition    
  2. [Scott] Programming Language Pragmatics
    by Michael L. Scott, 3rd edition
  3. [GM] Programming Languages: Principles and Paradigms
    by Maurizio Gabbrielli and Simone Martini
  4. [Mitchell] Concepts in Programming Languages
    by John C. Mitchell
    Warning: Chapters 5-7 on Haskell are not in the printed book
           

Course Schedule

N.

DATE

Topics

Slides

Notes

1

Nov. 10, 2014

Introduction
Abstract Machines, Interpretation and Compilation

PLP-01.pdf

[GM], Chapter 1; [Scott], Chapter 1 (section 1-4 to 1-6).

2

Nov. 13, 2014

Structure of Compilers
Overview of simple Front-End: Predictive Parsing, Translation Schemes

PLP-02.pdf

[ALSU], Chapter 2.

3

Nov. 17, 2014

Structure of Compilers
Overview of simple Front-End: Lexical Analysis, Static Check, Intermediate Code Generation

PLP-03.pdf

[ALSU], Chapter 2.

4

Nov. 20, 2014

Lexical analysis
Regular expressions and definitions, Implementing critical parts of a lexer

PLP-04.pdf

[ALSU], Chapter 3.

5

Nov. 24, 2014

Lexical analysis
Designing a lexer generator
Finite state automata

PLP-05.pdf

[ALSU], Chapter 3.

6

Nov. 27, 2014

From Regular Expression to DFA, directly
Minimization of DFA's
Exercises on lexical analysis

PLP-06.pdf

[ALSU], Chapter 3.

7

Dec. 1, 2014

Exercises on Lexical analysis

Proposed exercises: ES-PLP-2014-01-lexer.pdf

See the (non-marked) exercises proposed in [ALSU], Chapter 3, concerning the topics presented in class.

8

Dec. 4, 2014

Top-Down Parsing

PLP-07.pdf

[ALSU], Chapter 4.

9

Dec. 11, 2014

Bottom-Up Parsing

PLP-08.pdf

[ALSU], Chapter 4.

10

Dec. 15, 2014

LR parsing: Ambiguous grammars and Error detection; Exercises on parsing

PLP-09.pdf

[ALSU], Chapter 4.

11

Dec. 18, 2014

First Midterm Exam

The text of the exam is published on the Moodle platform

Where? Room A
When? 4 pm

It is necessary to register at URL https://esami.unipi.it/esami/studentportal.php before Dec. 12, 2014.

The exam will be about the material presented during the lessons and covered by Chapter 1 of [GM], Chapter 1 (sec. 1-4 to 1-6) of [Scott], and Chapters 2, 3 and 4 of [ALSU], with the exception of Sections 4.7.5, 4.7.6 and 4.9.

12

Tue, Feb. 24, 2015
9-11 am
Room L1

Syntax-Directed Translation I

PLP-10.pdf

[ALSU], Chapter 5.

13

Fri, Feb. 27, 2015
11-13 am
Room A1

Syntax-Directed Translation II
Parser generators: YACC/BISON

PLP-11.pdf

[ALSU], Chapter 5.

14

Tue, Mar. 3, 2015
9-11 am
Room L1

Intermediate Code Generation I

Intermediate representations; Three address statements and their implementations; Syntax-directed translation to three address statements; Handling local names and scopes with symbol tables.

PLP-12.pdf

[ALSU], Chapter 6.

15

Tue, Mar. 10, 2015
9-11 am
Room L1

Intermediate Code Generation II

Declarations of (multi-dimensional) arrays; Access to elements of arrays; Logical and relational expressions; Flow-of-control statements with backpatching lists.

PLP-13.pdf

[ALSU], Chapter 6.

16

Wed, Mar. 11, 2015
4-6 pm
Room: L1

Static Analysis Checking

Static versus Dynamic Checking; Type checking; Type conversion and coercion.

PLP-14.pdf

[ALSU], Chapter 6.

17

Fri, Mar. 13, 2015
11-13 am
Room: A1

Exercises on Syntax-Directed Definitions and Translation Schemes

Proposed exercises: ES-PLP-2014-02-syntax-directed.pdf

[ALSU], Chapters 5 and 6.

18

Tue, Mar. 17, 2015
9-11 am
Room L1

Code Generation I

PLP-15.pdf

Proposed Homework

[ALSU], Chapter 8.

Command line calculator with Flex/Lex and Yacc/Bison - Lex specification: calc.l; Yacc specification: calc.y; Dot representation of the parser FSA: parser.dot; Simple makefile: Makefile; dot can be found at http://www.graphviz.org/.

19

Fri, Mar. 20, 2015
11-13 am
Room A1

Code Generation II

PLP-16.pdf

[ALSU], Chapters 8 and part of 9.

20

Tue, Mar. 24, 2015
9-11 am
Room L1

Concepts of Programming Languages: An Introduction

PLP-17.pdf

[Scott] Chapter 1, Sections 1-1 to 1-3.

21

Fri, Mar. 27, 2015
11-13 am
Room A1

Bootstrapping, Names and Binding Times

PLP-18.pdf

[Scott] Chapter 3, [GM] Chapter 4.

22

Tue, Mar. 31, 2015
9-11 am
Room L1

Object allocation and Scoping rules

PLP-19.pdf

[Scott] Chapter 3, [GM] Chapters 4 and 5.

23

Thu, Apr. 16, 2015
2-4 pm
Room L1

More on scopes, their implementation and closures

PLP-20.pdf

[Scott] Chapter 3, [GM] Chapters 4 and 5.

24

Fri, Apr. 17, 2015
11-13 am
Room A1

Control flow: Expression evaluation, Structured flow, Selection statements

PLP-21.pdf

[Scott] Chapter 6, [GM] Chapter 6.

25

Tue, Apr. 21, 2015
9-11 am
Room L1

Control flow: Iteration, Iterators and Recursion

PLP-22.pdf, up to page 32.

[Scott] Chapter 6, [GM] Chapter 6.

26

Fri, Apr. 24, 2015
11-13 am
Room A1

Continuation-passing style
Type systems

PLP-22.pdf, pages 33-36,

PLP-23.pdf.

[Scott] Chapter 7, [GM] Chapter 8.

Type systems; Type safety; Type checking [Equivalence, compatibility and coercion]; Primitive and composite types [Discrete and scalar types; tuples and records]

27

Tue, Apr. 28, 2015
9-11 am
Room L1

Composite types

PLP-24.pdf, up to page 36.

[Scott] Chapter 7, [GM] Chapter 8.

Composite Types: Arrays, Unions, Pointers. Value model vs. reference model of variables.

28

Wed, Apr. 29, 2015
4-6 pm
Room C1

Composite types
Type inference
Parameter Passing

PLP-24.pdf, pages 36-43
PLP-25.pdf
PLP-26.pdf, up to page 13

[Mitchell] Chapter 6: pages 118-136 (Type inference)
[Scott] Section 8.3 (Parameter Passing)
[GM] Sections 7.1 and 7.2 (Parameter Passing)

29

Tue, May 5, 2015
9-11 am
Room L1

Parameter Passing
Introduction to Haskell

PLP-26.pdf
PLP-27.pdf, up to page 16

[Scott] Section 8.3 (Parameter Passing)
[GM] Sections 7.1 and 7.2 (Parameter Passing)
[Mitchell] Chapter 5 (Introduction to Haskell)

The GHC compiler for Haskell can be downloaded at http://www.haskell.org/platform
An introductory tutorial of Haskell and additional documentation about the languafe can be found at http://www.haskell.org/

30

Thu, May 7, 2015
4-6 pm
Room L1

Introduction to Haskell
Type classes in Haskell

PLP-27.pdf
PLP-28.pdf, up to page 25

[Mitchell] Chapter 7 (Type classes in Haskell)

31

Tue, May 12, 2015
9-11 am
Room L1

Type classes in Haskell
The Maybe Monad

PLP-28.pdf
PLP-29.pdf, up to page 12

[Mitchell] Chapter 7 (Type classes in Haskell)
A very short tutorial on Monads: http://www.idryman.org/blog/2014/01/23/yet-another-monad-tutorial/

32

Fri, May 15, 2015
11-13 am
Room A1

The IO Monad of Haskell

PLP-29.pdf

Reading material about Haskell Monads:
[PeytonJohnes2008], up to page 18 (on the Moodle platform)
https://wiki.haskell.org/Monads_as_containers
https://wiki.haskell.org/Monads_as_computation

A list of tutorials on Monads: https://wiki.haskell.org/Monad_tutorials_timeline

33

Tue, May 19, 2015
9-11 am
Room L1

Lambda expressions and Stream API in Java 8

PLP-30.pdf

Reading material:
http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html
http://docs.oracle.com/javase/tutorial/collections/streams/index.html

34

Fri, May 22, 2015
11-13 am
Room A1

Exercises

Proposed exercises: ES-PLP-2014-03-ProgLang-Various.pdf

35

Tue, May 26, 2015
9-11 am
Room L1

Exercises

Proposed exercises: ES-PLP-2014-04-ProgLang-Various.pdf

36

May 29, 2015

Second Midterm Exam

The text of the exam is published on the Moodle platform

Where? Room Fib-C
When? 11 am

It is necessary to register at URL https://esami.unipi.it/esami/studentportal.php before May 27, 2015.

The midterm exam will be about the material presented during the lessons of the second semester, and covered by the following chapters:

  1. Chapters 4.9, 5, 6, 8 (excluded 8.10 and 8.11), 9.1 of [ALSU]
  2. Chapters 3, 6, 7, 8.3 of [Scott]
  3. Chapters 4, 5, 6, 8, 7.1, 7.2 of [GM]
  4. Chapters 5, 6, 7 of [Mitchell] (PDFs to be downloaded from the Moodle platform, not from the printed book)
  5. Java 8: Lambda expressions and streams
    http://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html
    http://docs.oracle.com/javase/tutorial/collections/streams/index.html