Btech Cse 6 Sem Compiler Design Pcs6i102 2019
Btech Cse 6 Sem Compiler Design Pcs6i102 2019
Btech Cse 6 Sem Compiler Design Pcs6i102 2019
com
Registration No :
Part- I
Q1 Only Short Answer Type Questions (Answer All-10) (2 x 10)
a) Is macro processing a phase in compilation? Justify your answer
b) List the various error recovery strategies for a lexical analysis.
c) Define left recursion. Eliminate left recursion from the following grammar
E → E+T | T
T → T*F | F
F → (E) | id
d) Explain the purpose of semantic analysis in a compiler.
e) List the rules for computing Follow set of a grammar
f) What optimization can you propose for the following code
a := b*c;
x := b*c +5;
g) Mention the conflicts that occur in shift-reduce parser.
h) Mention the strategies of storage allocation.
i) Draw the annotated parse tree for “int a, b, c;”
D T L; | L.inh = T.type
T int | T.type = integer
T float | T.type = float
L L1, id | L1.inh = L.inh
| addType (id.entry, L.inh)
L id | addType( id.entry, L.inh)
j) Why symbol table is required? List various attributes of symbol table.
Part- II
Q2 Only Focused-Short Answer Type Questions- (Answer Any Eight out of Twelve) (6 x 8)
a) Construct the NFA that consists of all strings of a’s and b’s where third symbol from th right
end is ‘a’. convert the NFA to corresponding DFA.
b) Define Context free grammar. Find out the context fee grammar for the following languages
that consists of all the strings of a’s and b’s where
i) Every string starts and ends with the same symbol.
ii) L={ambncp | n= m+p and m, n, p ≥ 0}
c) State the various phases of a compiler, indicating the inputs and outputs of each phase in
translating the statement “position = initial + rate * 60”
d) Explain various issues associated with grammars in top-down parsing with suitable
example.
e) Explain different type expressions with example.
http://www.bputonline.com
http://www.bputonline.com
Part-III
Only Long Answer Type Questions (Answer Any Two out of Four)
Q3 Consider the following grammar (16)
E → E+T | T
T → T*F | F
F → (E) | id
a) Find the CLR parser for the above grammar.
b) Show the parsing of the string “((id + id) * id) + id” using the parsing table constructed
above.
Q4 What are the various intermediate forms? Mention its types. How would you implement the (16)
three address statements? Generate intermediate code for the following program fragment.
Assume there are four bytes per word
sum=0;
for(i=1;i<=20;i++)
sum = sum + a[i] + b[i];
Q6 What is an activation record? Draw diagram of General Activation record and explain the (16)
purpose of different fields of an activation record.
http://www.bputonline.com