Fall 2021 - CMPT 379 D100

Principles of Compiler Design (3)

Class Number: 4611

Delivery Method: In Person


  • Course Times + Location:

    Mo, We, Fr 9:30 AM – 10:20 AM
    SSCC 9002, Burnaby

  • Exam Times + Location:

    Dec 20, 2021
    3:30 PM – 6:30 PM
    SSCC 9000, Burnaby

  • Prerequisites:

    MACM 201, (CMPT 295 or ENSC 215) and CMPT 225, all with a minimum grade of C-.



This course covers the key components of a compiler for a high level programming language. Topics include lexical analysis, parsing, type checking, code generation and optimization. Students will work in teams to design and implement an actual compiler making use of tools such as lex and yacc.


As Steve Yegge said, "If you don't know how compilers work, then you don't know how computers work." (http://steve-yegge.blogspot.ca/2007/06/rich-programmer-food.html) This is a course for those who are interested in the design and implementation of programming languages. Compilers let us to use a high-level programming language by translating programs into low-level machine code. Understanding how compilers work is essential if you want to be a good programmer. In this course, you will build a working compiler using lex, yacc and LLVM (it's ok if you don't know what those terms mean).


  • Overview of a compiler
  • Lexical Analysis: regular expressions
  • Simple Parsing: context-free grammars, top-down and bottom-up parsing
  • LL(1) parsing: efficient top-down parsing
  • Shift-reduce parsers: introduction to bottom-up parsing
  • SLR/LR parsing: fast and efficient bottom-up parsing
  • Type checking: checking semantics of programs
  • Semantics and code generation: from a high-level language to assembly language
  • Optimization: an introduction to various types of code optimization


  • The grade distribution will be handed out at the start of classes. Students must attain an overall passing grade on the weighted average of exams in the course in order to obtain a clear pass (C- or better).



Reference Books

  • Compilers: Principles, Techniques and Tools (2nd Edition), A. V. Aho, M. S. Lam, R. Sethi, and J. D. Ullman, Addison-Wesley, 2006, 9780321486813, The purple dragon book

Registrar Notes:


SFU’s Academic Integrity web site http://www.sfu.ca/students/academicintegrity.html is filled with information on what is meant by academic dishonesty, where you can find resources to help with your studies and the consequences of cheating.  Check out the site for more information and videos that help explain the issues in plain English.

Each student is responsible for his or her conduct as it affects the University community.  Academic dishonesty, in whatever form, is ultimately destructive of the values of the University. Furthermore, it is unfair and discouraging to the majority of students who pursue their studies honestly. Scholarly integrity is required of all members of the University. http://www.sfu.ca/policies/gazette/student/s10-01.html


Teaching at SFU in fall 2021 will involve primarily in-person instruction, with approximately 70 to 80 per cent of classes in person/on campus, with safety plans in place.  Whether your course will be in-person or through remote methods will be clearly identified in the schedule of classes.  You will also know at enrollment whether remote course components will be “live” (synchronous) or at your own pace (asynchronous).

Enrolling in a course acknowledges that you are able to attend in whatever format is required.  You should not enroll in a course that is in-person if you are not able to return to campus, and should be aware that remote study may entail different modes of learning, interaction with your instructor, and ways of getting feedback on your work than may be the case for in-person classes.

Students with hidden or visible disabilities who may need class or exam accommodations, including in the context of remote learning, are advised to register with the SFU Centre for Accessible Learning (caladmin@sfu.ca or 778-782-3112) as early as possible in order to prepare for the fall 2021 term.