Department of Computer Science
CSU Stanislaus
California State University

CS4300-001: Compiler Theory

Fall 2022


 

Instructor: Dr. Xuejun Liang

My Office: DBH 282

Office Hours: MWF 1:00 p.m. - 2:00 p.m.

Phone : (209) 667-3169, Email: xliang@cs.csustan.edu

 

Class Information:

Classroom: DBH 103

Class Date & Time: 2:00 p.m. – 3:15 p.m.

Class Website: https://www.cs.csustan.edu/~xliang/Courses2/CS4300-22F

Class Server: wozniak.csustan.edu (You can use PuTTY to remote login.)

 

Course Materials

Required Textbook

Compilers: Principles, Techniques, & Tools, 2/E, by Alfred V. Aho, Monica S. Lam, Ravi Sethi and Jeffrey D. Ullman, Addison Wesley, 2007. ISBN: 9-780-321-486-813

 

Computer Accounts for Programming Assignments

Check your account here (Accounts)

 

Reference Textbooks

1.      Compiler Construction: Principles and Practice, by Kenneth C. Louden, PWS Publishing Company, 1997

2.      flex & bison: Text Processing Tools, by John Levine, O'Reilly Media, Inc., 2009

3.      Modern Compiler Implementation in Java, 2/E, by Andrew W. Appel and Jens Palsberg, Cambridge University Press, 2002

4.      Modern Compiler Implementation in C, by Andrew W. Appel and Maia Ginsburg, Cambridge University Press, 2004

5.      Advanced Compiler Design and Implementation, by Muchnick Steven, Morgan Kaufmann, 2008

6.      Engineering a Compiler, 2nd Edition, by Keith Cooper and Linda Torczon, Addison Wesley, 2011

 

Handouts

1.      Cool Reference Manual

2.      Tour of Cool Support Code

3.      Cool Runtime System

4.      Cool Example Programs

5.      SPIM Simulator manual

6.      Cool Java Documents

 

Reference Materials

1.      Flex manual

2.      JLex manual

3.      JFlex manual

4.      Bison manual

5.      Java CUP manual

6.      Lex - A Lexical Analyzer Generator

 

Lecture Slides with the Textbook

1.      Chapter 1: Introduction

2.      Chapter 2: A Simple Syntax-Directed Translator

3.      Chapter 3: Lexical Analysis

4.      Chapter 4: Syntax Analysis (a)

5.      Chapter 4: Syntax Analysis (b)

6.      Chapter 4: Syntax Analysis (c)

7.      Chapter 5: Syntax-Directed Translation (a)

8.      Chapter 5: Syntax-Directed Translation (b)

9.      Chapter 6: Intermediate-Code Generation (a)

10.  Chapter 6: Intermediate-Code Generation (b)

11.  Cool 1

 

New Lecture Slides with the Textbook

1.      Chapter 1: Introduction (A)

2.      Chapter 2: A Simple Syntax-Directed Translator (A, B, C, D)

3.      Chapter 3: Lexical Analysis (A, B, C, D)

4.      Chapter 4: Syntax Analysis (A, B, C, D, E, F, G, H)

5.      Chapter 5: Syntax-Directed Translation (A, B, C, D)

 

Course Syllabus and Major Topics

 

Course Description

This course is an introduction to the major methods used in compiler implementation. The parsing methods of LL(k) and LR(k) are covered as well as finite state methods for lexical analysis, symbol table construction, internal forms for a program, run time storage management for block structured languages, and an introduction to code optimization.

 

Course Outcomes

Students who successfully complete the course should be able to

1.      Build a compiler for a (simplified) programming language

2.      Know how to use compiler construction tools, such as generators of scanners and parsers

3.      Use and apply algorithms for lexical analysis

4.      Write and apply LL(1), LR(1), and LALR(1) grammars

5.      Pick an intermediate representation, translate expressions, and check types.

  1. Understand how the compiler create and manage a run-time environment to support execution of its target programs

7.      Know how the code generator perform instruction selection, register allocation and assignment, and instruction ordering

 

Homework Assignments

1.      Homework #1

2.      Homework #2 (2a)

3.      Homework #3 (2b)

4.      Assignment #4 (3a)

5.      Assignment #5 (3b)

6.      Assignment #6 (4a)

7.      Assignment #7 (4b)

8.      Assignment #8 (4c-1)

9.      Assignment #9 (4c-2)

10.  Assignment #10 (4d)

11.   

 

Programming Assignments

1.      Lex/Yacc Programming (download)

 

Programming Projects (Thanks to Professor Alex Aiken)

1.      Project #1 (Cool programming: Stack machine)

2.      Project #2 (Cool Scanner)

3.      Project #3 (Cool parser)