CMPT-379 - Fall 2007 - Principles of Compiler Design

This is a course for those who are interested in the design and practice of programming languages. If you want to learn how to design and implement your own programming language, then take this course. Every computing device built today needs a compiler. It enables us to use a high-level programming language like C or Java by translating programs into low-level machine code. Understanding how compilers work is essential if you want to be a good programmer. The study of compilers also includes interesting ideas in translation and optimization with sparse resources. As part of the course, the carefully designed assignments will allow students to implement a working compiler using standard compiler tools.

More details: Course outline

Important Dates

Programming Assignments

Supporting files

In order to complete some parts of your assignments, you will need to refer to the following files:

The MIPS virtual machine, spim is available in the directory ~anoop/cmpt379/spim.linux/ for the CSIL Linux machines, and the directory ~anoop/cmpt379/spim.solaris/ if you are running on fraser.sfu.ca

You can download spim but make sure you use version 6.5 and also you must make absolutely sure that your code runs on the CSIL Linux machines before you submit your homework code.

Homeworks

Notes on assignment submission and development

You must use a makefile to compile your program, test and cleanup your program output. Running "make" should compile your program and running "make test" should run any tests on sample inputs.

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.

In addition, we will be using flex (preferably version 2.5.33) and bison (preferably version 2.3) in order to build our compiler.

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.

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".

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. Simple Syntax-directed translations, Abstract Syntax Trees
  6. Syntax-directed Translation and Semantics
  7. Translation to Intermediate Code
    • Chp 6 (excluding Chp 6.3 to 6.5)
    • Notes #11 (11/13/07)
  8. Run-time Environment, Stack frames and parameter passing
  9. Code Generation and Register Allocation
  10. Code Optimization
  11. Wrap-up

Course Expectations and Policies


anoop at cs.sfu.ca