Compiler Construction Instructor : Dr. Tiayyba Riaz
[email protected] Fall - 2014 Course Code : CS4435 Credit Hours : 3 Class : BS Course Description: CS4435 provides the students with an opportunity to learn issues that arise in the design and construction of translators for programming languages. The course emphasizes techniques that have direct application to the construction of compilers. Not to forget many of the same concepts find application in the implementation of interpreters. Course Objectives: The aim of this module is to show how to apply the theory of language translation introduced in the prerequisite courses to build compilers. This course provide a thorough understanding of the basic structure of compilers for a programming language. A major part of the course consists of the implementation of a compiler for a simplified programming language. Student Learning Outcomes On completion of this unit students should be able to understand: 1. How the compiler works. 2. Phases of the compiler. 3. Implementation details of the compiler phases. Course Outline Date
Lecture
Description
Readings
Remarks
Week 1
Lecture 1
Introduction and course overview. Compilers, language processors, structure of compiler Introduction to lexical analysis, Role of Lexical Analyzer
Chapter 1 Sections: 1.1, 1.2
Introduction
Chapter 3 Sections: 3.1
Lexical Analyzer
Lecture 3
Specifications of tokens, Recognition of Tokens
Chapter 3 Sections: 3.2, 3.3
Lexical Analyzer
Lecture 4
Implementation details of Lexical Analyzer, Discussion of Programming Assignment 1 (PA1) in class
Chapter 3 Sections: 3.4
PA 1 out
15/09 - 19/09 Lecture 2 Week 2 22/09 - 26/09
Week 3
Lecture 5
Syntax Directed Translation, Syntax Definition
Chapter 2 Section: 2.1, 2.2
CFG
Lecture 6
Syntax Analysis/Parsing : Roler of Parser, Syntax Error Handling
Chapter 4: Syntax analysis Sections 4.1, 4.1.1
Scanning/ Parsing
Scanning/ Parsing
29/09 - 03/10
Week 4 06/10 - 10/10 Week 5
Eid ul Adha Holidays Lecture 7
Context Free Grammar, Writing a Grammar, Elimination of Ambiguity, Elimination of Recursion
Chapter 4: Syntax analysis Sections: 4.2, 4.3
Lecture 8
Parsing Algorithms, Top down Parsing, Recursive Decent Parsing
Chapter 4: Syntax analysis Sections: 4.4
Lecture 9
First and Follow, LL(1) grammar
Lecture 10
Non recursive Predictive Parsing, Error Recovery in Predictive Parsing
Lecture 11
Bottom Up Parsing, Reductions, Handle Pruning, Shift-Reduce Parsing, Conflicts During Shift-Reduce Parsing Introduction to LR Parsing, Why LR Parsers?, Items and the LR(O) Automaton
Chapter 4: Syntax analysis Sections: 4.4 Chapter 4: Syntax analysis Sections: 4.4 Chapter 4 : Sections : 4.5
13/10 - 17/10
Week 6 20/10 - 24/10
Week 7 27/10 - 31/10
Lecture 12
Week 8
Lecture 13
The LR-Parsing Algorithm
03/11 - 07/11
Lecture 14
Constructing SLR-Parsing Tables
Week 9 10/11 - 14/11
Quiz 1 Scanning/ Parsing PA 1 due Scanning/ Parsing Scanning/ Parsing Scanning/ Parsing
Chapter 4 : Sections : 4.5
Scanning/ Parsing
Chapter 4 : Sections : 4.6
PA2 out Scanning/ Parsing Scanning/ Parsing
Mid Term Exam
Week 10
Lecture 15
Introduction to Semantic Syntax-directed definitions Evaluation Orders for SDD
Analysis
using
Chapter 5: Sections : 5.1 Chapter 5 : Sections : 5.2 Chapter 5 : Sections : 5.3
Semantics
17/11 – 21/11
Lecture 16
Week 11
Lecture 17
Applicatios of Syntax directed translation: Bottom-up evaluation of S-attributed definitions
Lecture 18
Top down translation
Chapter 5: Sections : 5.4 Chapter 5(*Ed 1) Section : 5.5
Semantics
Lecture 19
Top down translation
Lecture 20
Bottom up evaluation of inherited attributes
Chapter 5(*Ed 1) Section : 5.5
Semantics PA2 due
Lecture 21
Intermediate Code generation
Chapter 6
Semantics
Semantics Semantics
24/11 – 28/11
Week 12
Semantics
01/12-05/12
Week 13
Variants of Syntax Trees, three address codes 08/12-12/12 Week 14
Declarations,
Translation
Sections: 6.1, 6.2
Lecture 22
Types and Expressions
of
Chapter 6 Sections : 6.3
Lecture 23
Type Checking I
Sections : 6.5
Lecture 24
Type Checking II
Sections : 6.5
Lecture 25
Run-time Environment Storage organization
Chapter 7 Section: 7.1
Lecture 26
Stack Allocation of Space
Chapter 7 Section: 7.2
Intermediate Code generation Quiz 2 Intermediate Code generation Intermediate Code generation Intermediate Code generation Run-time Environment
Lecture 27
Access to Nonlocal Data on the Stack
Chapter 7 Section: 7.3
Run-time Environment
Lecture 28
Heap Management
Chapter 7 Section: 7.4
Run-time Environment
15/12-19/12 Week 15 22/12-26/12
Week 16 29/12-02/01
Week 17 05/01-09/01
Week 18 12/12-16/01
Project Evaluation