Extra Material for CS 4TB3

Past Lectures

Introductory lectures

The first couple of weeks used Graydon Hoare's One-Day Compilers as material for motivating and explaining the basics of compilers.

Interpreters

The first interpreter (using data-structures to represent the language), and the second interpreter using the module system and smart constructors. That second one was based on the the tagless final approach to interpreters, fully documented in Finally tagless, partially evaluated: tagless staged interpreters for simpler typed languages. One can also get more details, including source code, from Oleg's pages, where one can also find lecture notes for a curse on the topic.

Parsing

Beyond LR, LL and LALR parsing, there is a brave new world of 'modern' parsers. There are a whole host of parser generators following all sorts of different ideas.

Of particular interest are

There are also whole frameworks, like MPS for language development which include parsing technologies. See also Stratego.

Context analysis

The analyse.ml code, as done in class. It will get updated soon with a completed type checker.

LLVM

The main information is of course at llvm.org. The slides presented in class combine information from LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation and The LLVM Compiler Framework and Infrastructure Tutorial.

There is a really nice tutorial (using C) for compiling from Kaleidoscope (a little language) to LLVM. Conveniently, there is also an O'Caml version of the same tutorial!

To make the job easier, there are

  1. O'Caml bindings (ships with LLVM)
  2. Python bindings
  3. Haskell bindings (on Hackage even!)
  4. A discussion of the options for a Scala bindings (there are of course Java bindings, which can be used in Scala)
Some of you might want to take a peek at LLVM-LUA or at a native code compiler for MiniML in ~100 lines of O'Caml (using LLVM).