Computer Laboratory

Course pages 2011–12

Compiler Construction

Primary Materials

Additional Exercises

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
  • 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


Last year’s course materials are still available and all of the links above except for this year's notes link to them.