CS 434
Compiler Design

  • Instructor
  • Texts
  • Lectures and Readings
  • Assignments, Projects and Grading

  • The design and construction of a compiler involves both theoretical issues of algorithm design and practical issues of software engineering. In this course we will look at both of these aspects of compiler construction. The course will involve a large software project intended to expose you to the engineering aspects of managing a large project and to familiarize you with the basic problems that must be addressed in an any compiler. In class, we will explore the techniques that have been developed for lexical analysis, parsing, code generation and optimization.

    Instructor

    Tom Murtagh
    Office: 126 Bronfman
    Phone: 597-2369
    Hours: Wed. & Fri. 1:15-2:30
    Mon. & Tue. 10:00-11:00

    Texts

    A+U
    Aho, Alfred V. and Ullman, Jeffrey D., Principles of Compiler Design, Addison Wesley Publishing Co., 1978.
    AS+U
    Aho, Alfred V., Sethi, Ravi and Ullman, Jeffrey D., Compilers: Principles, Techniques and Tools, Addison Wesley Publishing Co., 1986.
    F+H
    Field, Anthony J. and Harrison, Peter G., Functional Programming, Addison Wesley Publishing Co., 1988.
    F+L
    Fisher, Charles, N. and LeBlanc, Richard J., Crafting a Compiler, Benjamin/Cummings Publishing Co., Inc., 1988.
    K+R
    Kernighan, B.W. and Ritchie, D.M., The C Programming Language, Prentice Hall, 1978.
    W+G
    Waite, Williams M. and Goos, Gerhard, Compiler Construction, Springer-Verlag, 1984.

    There are no required texts for this course. Instead, I will place several of the texts listed above on reserve. Below, in the list of topics planned for our class meetings, I have indicated which sections of these texts might be appropriate readings to accompany the topics discussed in class. I have used the authors initials (i.e. F+L, A+U, ...) to refer the texts in the list of readings. I will provide additional guidance to possible readings in class when appropriate.

    Lectures and Readings

    The following is a tentative schedule of lectures with associated readings.

    Date Topic Readings

    1. 2/5

    The Structure of a Compiler.
    • F+L Ch. 1 + Ch. 2.
    • A+U Ch. 1.
    • AS+U Chs. 1 + 2.

    2. 2/8, 2/10, 2/12

    Symbol Table Organization.
    • F+L §7.1.1, 8.1, 8.2, 8.3, 8.4.1.
    • A+U Ch. 9.
    • AS+U §7.6.

    3. 2/15

    Run-time Storage Organization.
    • F+L §9.1, 9.2, 13.2.1, 13.2.2.
    • A+U Ch. 10 (except §10.3).
    • AS+U §7.1-7.4.

    4. 2/17, 2/22

    Variable Reference and Type Checking.
    • F+L §10.1, 10.2, 13.2.3.
    • AS+U §6.1-6.4, 8.2.

    5. 2/24, 2/26

    Formal Specification of Syntax.
    • F+L §2.0, 2.3, 4.1, 4.2, 4.3.
    • A+U Ch. 4.
    • AS+U §4.1-4.3.

    6. 3/1, 3/3

    Code Generation for Expressions.
    • F+L §11.1, 11.2.
    • A+U §7.1-7.8, 8.1.
    • AS+U §8.1, 8.3, 9.1.

    7. 3/5, 3/8

    Code Generation for Control Structures.
    • F+L §12.1, 12.2, 12.7.
    • A+U §7.9.
    • AS+U §8.4.

    8. 3/10, 3/12

    An Introduction to Parsing.
    • F+L §2.4, 4.4, 6.1, 2.1, 2.5, 7.1.2, 7.1.3, 7.2.2.
    • A+U §5.1, 5.2, 5.4.
    • AS+U §4.4, 4.5.

    9( pt.1). 3/15, 3/17

    Code Generation for Procedures and Procedure Calls.
    • F+L §13.1-4.
    • A+U §8.2.
    • AS+U §8.7.

    10. 3/19

    Dynamic Memory Management
    • F+H Ch. 16
    • F+L §9.3
    • AS+U §7.7-7.8

    9( pt.2). 4/5

    Code Generation for Procedures and Procedure Calls.
    • F+L §13.1-4.
    • A+U §8.2.
    • AS+U §8.7.

    11. 4/7

    Parser Construction with Yacc.
    • handout distributed in class
    • F+L §6.7.2, 6.7.3
    • A+U §6.7.
    • AS+U §4.9.

    12. 4/9

    Scanner Generation.
    • F+L §3.1-3.3, 3.4.2, 3.6.
    • A+U Ch. 3.
    • AS+U Ch. 3.

    13. 4/12, 4/14, 4/16

    Intro. to LR Parsing.
    • F+L §6.1-6.2.1.
    • A+U §6.1-6.2.
    • AS+U §4.7 (up to p. 227).

    14. 4/19, 4/21, 4/23, 4/26

    Basic Code Improvement Techniques.
    • F+L §15.1-15.5.
    • A+U Ch. 12.
    • AS+U §10.1-10.3.

    15. 4/28

    The Correctness of LR(0) parsing
    • F+L §6.2.2.
    • A+U §6.3.
    • AS+U §4.7 (pp. 227-230).

    16. 4/30

    SLR, LR(1) and LALR Parsing.
    • F+L §6.3-6.5.
    • A+U §6.4, 6.5.
    • AS+U §4.7 (pp. 230 -> ).

    5/5

    Mid(?)term Exam Sample midterm from Fall 1994

    16.5 5/3, 5/5

    SLR, LR(1) and LALR Parsing. (cont.)
    • F+L §6.3-6.5.
    • A+U §6.4, 6.5.
    • AS+U §4.7 (pp. 230 -> ).

    17. 5/7, 5/10, 5/12

    Analysis for Code Improvement.  

    Assignments, Projects and Grading

    Most of the programming assignments for the course will be components of the construction of a compiler for a specially designed programming language. In addition, there will be written assignments designed to expose you to aspect of compiler construction not touched on in the main project. Your work on all homeworks and programs must conform to the "Honor Code Guidelines for Computer Science Courses" handout which I will make available. In interpreting these guidelines all the programs in this course should be treated as "homework programs".

    There will be a midterm (probably) and a final examination. Both exams will be "self-scheduled" open-book examinations. Final grades will be based on an average obtained by treating homework scores as 15%, project grades as 35%, the midterm as 20% and the final as 30%.

    Project Schedule


    Phase Assigned Duration Description
    1.1 2/10 9 days Basic Declaration Processing: Type and Variable Declarations
    1.2 1/19 12 days Identifier Reference Processing and Type Checking
    2.1 3/3 9 days Code Generation for Expressions
    2.2 3/12 7 days Code Generation for Control Structures
    2.3 3/19 ?? days Code Generation for Procedures
    ??? 4/12 9 days Parser and Scanner Construction
    3.1 4/21 9 days Constant Folding
    3.2 4/30 7 days Common Subexpression Identification
    3.3 5/7 7 days Common Subexpression Elimination

    Links to the descriptions of the project phases will appear above as the course progresses.


    Homework Exercises: