Course pages 2011–12
Compiler Construction
Primary Materials
Additional Exercises
- 2009 exercises : exercises_2009.txt,
- 2010 exercises : exercises_2010.html.
Lecture-specific materials
- Lecture 1
- Assembler and object files
Input file : test1.c
Assembler code (generated with gcc -S test1.c): test1.s
Object file (generated with gcc -c test1.c): test1.o
Object file in ASCII (generated with readelf -a -t test1.o > test1.o.elf.txt): test1.o.elf.txt
Executable (generated with gcc -o test1 test1.c): test1
Executable in ASCII (generated with readelf -a -t test1 > test1.elf.txt): test1.elf.txt
- Assembler and object files
- Lecture 4: See the 2009-10 additional materials (in particular the Syntax Tree/Lambda Interpreter in ML) on this link Further Materials.
- Lecture 5: Simple lexical analyser input and output files. Note, for real use, the printf statements would be replaced with return statements so this lexer can be called as a subroutine from the syntax analyser.
- Lecture 11: Trampoline Recursion: Is it possible in ML / F Sharp ?
val fact = (fn f => (fn x => if x=1 then 1 else x * f f (x-1))) ; val test = fact fact 5; OR val fact1 = (fn (f, x) => if x=1 then 1 else x * f(f, x-1)); val test = fact1(fact1, 5); OR if you don't like the replication of 'meta label' fact1 we can write it purely anonymously: (fn fact1 => fact1(fact1, 5)) (fn (f, x) => if x=1 then 1 else x * f(f, x-1));
Supplemental Materials
- ALL HAIL GRACE HOPPER!
-
X86 Assembly.
The Art of Assembly (online Book containing more than most of us will ever know).
MIPS Assembly.
ARM Assembly.
-
What is a Linker?
Beginner's Guide to Linkers
The Linux ELF HOWTO, by Daniel Barlow
-
What is a Loader?
Linkers and Loaders by John Levine.
-
The JAVA Virtual Machine (JVM)
JVM bytecodes
BCPL was doing bytecodes long before they were cool.
- Prolog is typically implemented with a virtual machine.
The Warren Abstract Machine -
Parsing
Lex and Yacc
Yacc is not the only parser generator
Example calculator using Lex and Yacc:
- Makefile
- Lex specification and
- Yacc specification
- Instructions: Download these three files to an empty directory and say "make". If yacc is not installed on your machine, bison may be used instead. Run it by saying "calc". Input lines are things like "1+2*3" "(1+2)*3" etc.
-
Educational compilers.
MinCaml from Eijiro Sumii
Cool = Classroom Object Oriented Language, from Alexander Aiken
VSPL from Martin Richards
-
Selected open source compilers.
GCC, the GNU Compiler Collection
The LLVM Compiler Infrastructure (see the tutorial)
Jikes for Java
The Amsterdam Compiler Kit
Standard ML of New Jersey
whitespace
Moscow ML
OCaml
The Glasgow Haskell Compiler
-
Selected experimental compilers.
Cyclone --- a safe dialect of C.
Idris --- A systems programming language with dependent types.
Last year’s course materials are still available and all of the links above except for this year's notes link to them.