Ics 603 CD
Ics 603 CD
Teacher Name:
Course Structure
Course Content:
Unit-1:
Introduction to Compiler, Phases and passes, Bootstrapping, Finite automata & regular
expressions and their applications to lexical analysis, Implementation of lexical analyzers,
lexical-analyzer generator, LEX-compiler, The syntactic specification of Programming
languages: Context free grammars, derivation and parse trees, capabilities of CFG,
Application of grammars in syntax analysis, ambiguity and BNF notation, YACC.
Unit-2:
Basic Parsing Techniques: Parsers, top down parsing, Shift reduces parsing, operator
precedence parsing, predictive parsers. Automatic Construction of efficient Parsers: LR
parsers, the canonical Collection of LR(0) items, constructing SLR parsing tables,
constructing Canonical LR parsing tables, Constructing LALR parsing tables, using
ambiguous grammars, an automatic parser generator, implementation of LR parsing tables,
constructing LALR sets of items.
Unit-3:
Course Outcomes:
1. Describe the role of each phase of a compiler with its construction tools. (Understand)
2. Develop a Lexical Analyzer for recognizing tokens of a given language with an understanding
of symbol table management and error handling. (Apply)
3. Construct top-down, bottom-up, operator precedence and SLR parsers with an
understanding of Context Free Grammars and syntax analysis. (Apply)
4. Design and develop semantic analyzers for type-checking and intermediate code generators
to translate the source program into an intermediate code. (Apply)
5. Construct code optimizers to optimize the target code generated. (Apply)
Lesson Plan
LECTURE PLAN
COMPILER DESIGN (ICS-603)
Lecture Unit/Topic/Subtopic Teaching Learning Remarks
No. Method(s) Material if any
UNIT 1:
1. Introduction to Compiler, Phases and Chalk and Books
passes, Bootstrapping Board and Notes
2. Finite automata and regular Chalk and Books
expressions and their applications to Board and Notes
lexical analysis,
3. Implementation of lexical analyzers, Chalk and Books
lexical-analyzer generator, LEX Board and Notes
compiler.
4. The syntactic specification of Chalk and Books
Programming languages: Context free Board and Notes
grammars,
5. derivation and parse trees, capabilities of Chalk and Books
CFG. Board and Notes
6. Application of grammars in syntax Chalk and Books
analysis, Board and Notes
7. ambiguity and BNF notation, YACC. Chalk and Books
Board and Notes
UNIT – 2
Assignment 1
Instructor: Ankita Gautam
Compiler Design (2018-19)
11. Construct the recursive decent parser for the string id*(id+id) following grammar?
E-> E+T/T
T-> T*F/F
F->(E)/id
Assignment 2
Instructor: Ankita Gautam
Compiler Design (2018-19)
3. Consider SLR(1) and LALR(1) tables for CFG. Which of the following is false?
a. Goto of both tables may be different
b. Shift entries are identical in both tables
c. Reduce entries in tables may be different
d. Error entries in tables may be different
4. Consider the grammar S → CC, C → cC | d is
a. LL(1)
b. SLR(1) but not LL(1)
c. LALR(1) but not SLR(1)
d. LR(1) but not LALR(1)
S→L=R|R
L → * R | id
R→L
9. How many conflicts occur in DFA with LR(1) items for the following grammar?
S → SS | a | c
10. Consider the following two sets of LR(1) items of an LR(1) grammar.
X -> c.X, c/d
X -> c.X, $
X -> .cX, $
X -> .d, $
b. 2 only
c. 1 and 4 only
d. 1, 2, 3, and 4
Assignment 3
1. Explain syntax directed definition.
2. Explain the Translation scheme of SDD.
3. Draw the syntax tree and DAG for the following expression:
(a*b)+(c-d)*(a*b)+b
4. Differentiate between synthesized translation and inherited translation.
5. What is intermediate code and write the two benefits of intermediate code generation.
6. Write short notes on:
a. Abstract syntax tree
b. Polish notation
7. Write quadruples, triples and indirect triples for the expression:
-(a*b)+(c+d)-(a+b+c+d)
Assignment 4
1. Define Symbol table. Explain different types of Data structure for symbol table
2. Draw the format of Activation Record in stack allocation and explain each field in it.
3. Distinguish between static scope and dynamic scope. Briefly explain access to non-local
names in static scope.
4. What is meant by data flow equation?
5. What is activation record? Write the various fields of Activation Record.
6. What are the functions of error handler?
7. Write a short note on Error Detection and Recovery.
8. Classify the errors and discuss the errors in each phase of Compiler.
Assignment 5
1. Construct the DAG for the following basic blocks
a. t1:=4*i
b. t2:=a[t1]
c. t3:=4*i
d. t4:=b[t3]
e. t5:=t2*t4
f. t6:=prod+t5
g. prod:=t6
h. t7:=i+1
i. i:=t7
j. if i<=20 goto 1
2. Explain the simple code generator and generate target code sequence for the following
statement d:=(a-b)+(a-c)+(a-c)