Fall 2020 - CMPT 379 D100

Principles of Compiler Design (3)

Class Number: 6616

Delivery Method: In Person


  • Course Times + Location:

    Mo 9:30 AM – 10:20 AM

    We, Fr 9:30 AM – 10:20 AM

  • Prerequisites:

    MACM 201, (CMPT 150, CMPT 295 or ENSC 215) and CMPT 225.



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 2020 will be conducted primarily through remote methods. There will be in-person course components in a few exceptional cases where this is fundamental to the educational goals of the course. Such course components will be clearly identified at registration, as will course components that will be “live” (synchronous) vs. at your own pace (asynchronous). Enrollment acknowledges 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. To ensure you can access all course materials, we recommend you have access to a computer with a microphone and camera, and the internet. In some cases your instructor may use Zoom or other means requiring a camera and microphone to invigilate exams. If proctoring software will be used, this will be confirmed in the first week of class.

Students with hidden or visible disabilities who believe they may need class or exam accommodations, including in the current context of remote learning, are encouraged to register with the SFU Centre for Accessible Learning (caladmin@sfu.ca or 778-782-3112).