CMPT-379 - Fall 2006 - Principles of Compiler Design

Every computing device built today needs a compiler. It enables us to use a programming language by translating programs into machine code. Understanding how compilers work is essential if you want to be a good programmer. The study of compilers also includes interesting theoretical ideas in translation and optimization with sparse resources. This course covers the fundamentals of compiler theory used to build compilers for high level programming languages. We will cover each component of a compiler including lexical analysis, parsing, code generation, code optimization and type-checking. As part of the course, students will implement a working compiler. The programming language used for the homeworks will be either C, C++, Java (another programming language may be used if it is found to be relevant and interesting).

More details: Course outline

Announcements

Assignments

  1. Homework #1. Distributed on Mon, Sep 11, Due on Mon, Sep 18. Files are in ~anoop/cmpt379/hw1
  2. Homework #2. Distributed on Mon, Sep 18, Due on Mon, Sep 25. Files are in ~anoop/cmpt379/hw2
  3. Homework #3. Distributed on Mon, Sep 25, Due on Fri, Oct 6. Files are in ~anoop/cmpt379/hw3
  4. Homework #4. Distributed on Mon, Oct 9, Due on Mon, Oct 23. Files are in ~anoop/cmpt379/hw4
  5. Homework #5. Distributed on Mon, Oct 23, Due on Fri, Nov 3. Files are in ~anoop/cmpt379/hw5
  6. Homework #6. Distributed on Wed, Nov 8, Due on Mon, Nov 20. Files are in ~anoop/cmpt379/hw6
  7. Homework #7. Distributed on Mon, Nov 20, Due on Mon, Nov 27 (changed, see below). Files are in ~anoop/cmpt379/hw7
    • New Deadline: Homework #7 and Q.1 from Homework #8 is now due on Fri, Dec 1.
  8. Homework #8. Distributed on Mon, Nov 27, Due on Mon, Dec 4 (changed, see below).
    • Q.1 merged with Homework #7. Other components of the homework are now optional but due on Dec 1. Do not submit this homework on Dec 4.

Important note on assignment submission and development: Your homework will be submitted electronically using the department-provided submission server. Connect to the submission server by going to the URL: https://submit.cs.sfu.ca/

It is expected that your program will compile and run using the standard gcc or g++ compiler on the Linux CSIL lab machines. If you are developing on a Linux or Windows machine at home, you have to ensure that the code will run on the CSIL machines before you submit the assignment. Please either visit the CSIL lab machines or you can use ssh to login to the CSIL Linux machines and also use scp to copy over and test your programs on the CSIL Linux machines before you submit them. Check the CSIL Layout map for the machine names.

Note that the C++ compiler for gcc version 2.96 and gcc version 3.3.2 are seriously broken and will not be compatible with gcc on the CSIL machines. Check the version you are using by running the command gcc --version

For Windows machines, you might want to look into the use of the cygwin environment and the dos2unix command on Linux. There will be no extensions for problems with non-CSIL machines, so don't ask.

On some CSIL Linux machines, in some rare cases, you might have to extend your CPU time limit for a process. If you are using tcsh then run the command "limit cputime 1800" to extend CPU time to 1800 secs or 30 mins. If you are using bash then use the command "ulimit -t 1800".

The files for each homework are available in the directory ~anoop/cmpt379/. The directory is accessible only on the CSIL linux machines.

Use a makefile to compile your program, and test and cleanup your program output. Two examples are provided: a simple one in ~anoop/cmpt379/hw1 and a more complex one in ~anoop/cmpt379/howto-make. In the directory howto-make try the commands make, make test, make clean and make tarball.

Textbook and References

Syllabus and Readings

  1. Introduction to Compiler Design
  2. Lexical Analysis
  3. Formal languages and automata, Analysis of Ambiguity
  4. Syntax Analysis, Deterministic Parsing and sub-classes of CFGs
  5. Abstract Syntax Trees
  6. Stack Frames and Parameter Passing
  7. Syntax-directed Translation and Semantics
  8. Translation to Intermediate Code
  9. Code Generation and Register Allocation
  10. Code Optimization
  11. Wrap-up

Course Expectations and Policies


anoop at cs.sfu.ca