Teacher: Letterio Galletta
Contact: name.surname(at)imtlucca.it
Office hours: contact me by e-mail
Page of theory part of the course held by Prof. Roberta Gori: http://pages.di.unipi.it/gori/Linguaggi-Compilatori2022/
The course will present tools and techniques used in the implementation of programming languages. During the lectures students will work on programming assignments covering different aspects of language implementation. The programming language adopted for the exercises and the project is OCaml. At the end of the course students who completed all the assignments and the project will have developed an simple interpreter and a compiler.
After completing the course, students will have
- Known the basics of the functional programming language OCaml;
- Implemented parsers using state-of-the-art parsers generators;
- Designed and implemented semantic analyses for a functional and an imperative languages;
- Used the LLVM toolchain for generating and optimize code;
- Had some fun along the way! 😄
- Introduction to functional programming and to OCaml language;
- Lexing and parsing using
ocamllex
andmenhir
; - Semantic analysis implementation: type checking, scope management, control-flow analysis;
- Introduction to LLVM infrastructure and LLVM intermediate language;
- Code generation.
This table specifies the lecture schedule with topics and materials.
See these instructions to set up your programming environment.
The final project of the course consists in implementing a compiler for MicroC. See here for the instructions.
Programming assignments will use the following pieces of software:
- OCaml - try to install the latest version. All the code shown during the course is tested with the version 4.14.0.
- Opam - OCaml package manager.
- Menhir - a LR(1) parser generator for the OCaml programming language.
- Clang - a compiler for C programs.
- LLVM - The LLVM compiler infrastructure. All the code shown during the course is tested with the version 14.0.
- rlwrap - a small utility to improve the editing capability of the OCaml REPL.
- utop - an improved toplevel (i.e., Read-Eval-Print Loop) for OCaml.
- OCaml API
- OCaml user manual
- OCaml Discourse the community forum
- OCamlverse an attempt to documenting everything about OCaml
- The book OCaml Programming: Correct + Efficient + Beautiful
- The book Real World OCaml
- The book OCaml Scientific Computing
- OCaml MOOC
- The videos of the book OCaml Programming: Correct + Efficient + Beautiful
- An interactive tutorial on using
git
- LLVM Language Reference Manual
- LLVM OCaml Binding Documentation
- Kaleidoscope: Implementing a Language with LLVM in Objective Caml
- Mapping High Level Constructs to LLVM IR
- The Programming Languages Zoo - A potpourri of programming languages
- Compiler Explorer
- Resources for Amateur Compiler Writers
- CompilerJobs a list of compiler, language and runtime teams for people looking for jobs in this area.
Here you find a list of further references that complete and deepen the various topics covered during the course. A rich collection of articles related to the course can be found in Prof. Matt Might's blog.