0% found this document useful (0 votes)
20 views7 pages

CD Pyq

Uploaded by

rithikrawat2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views7 pages

CD Pyq

Uploaded by

rithikrawat2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

(Please write your Exam Roll No.] ,E,camRoll No .

• END TERM EXAMINATION


SIXTH SEMESTER MAY-JUNE 2016
Paper Code: ETCS-302 Subject: Compiler Design
Time: 3 Hours Maximum Marks: 75
Note: Attempt any five questions including Q. no.l which is compulsory.
Select one question from each unit.

Q1 Attempt all 10 questions. (lOx2.5:25)


(a) Distinguish between compiler and interpreter. Define Cross Compiler and
identify the few cases where such cross compiler will be useful.
(b) Design the Finite Automata for the regular expression a(a + b)a.
(c) Mention the role of Lexical Analyser in compiler design.
(d) What compiler check during the syntax analysis? Mention the role of parser
with the help of suitable figure during the syntax analysis.
(e) Define ambiguity in a grammar.
(f) What are the advantages of performing the LR parsing?
(g) Define FIRST and FOLLOW sets for a grammar.
(h) Perform recursive descent parsing over the input mpp for the grammar.
S~XY
X~ml mY
Y~p
(i) What is Peephole optimization? How is it performed? Give example of
peephole optimization.
Ul What is DAG? What are the advantages of using DAG?
UNIT-I
Q2 (a) Design a derivation tree for the following grammar: (5)
E~E+E I E-E I EjE I E*E I a I b. Also obtain the left most and rightmost
derivation tree for the string "a + b * a + b".
(b) Find whether the grammar is ambiguous or not: (7.5)
S ~ ABj aaB, A ~ ajAa, B ~ b
How to remove ambiguity from this grammar. !

Q3 (a) Consider the following grammar and Parse the input string int id, id; using
shift reduce parser.
S ~ TL; T ~ int I float L ~ L, id I id (5)
(b) Discuss all three methods which are used to perform the LR parsing. Which
technique is most powerful among these three? Give justification also. (7.5)

UNIT-II
Q4 What are the benefits for the three address code generation? Consider the input
string x: = - a * b + - a * b and generate the following: (12.5)
(a) Syntax Tree (b) Posix (c) Three address Code

Q5 (a) Draw the Syntax tree for the following piece of code in the source language:
If x> y then x = 3* (y+1) else y = y+ 1. (2.5)
(b) Write short comments on:- (10)
(i) LEX
(ii) YACC

P.T.O.
[2]

• UNIT-III
Q6 What is the significance of symbol table in compiler? What information is
represented by symbol tables? Explain the data structure used for symbol
tables. (12.5)

Q7 What is activation record? Briefly outline Run time storage administratioh.


Discuss different error handling techniques. ( \ 2· 5)

UNIT-IV
Q8 What are the criteria that need to be considered while applying the code
optimization technique? Mention the issues involved in designing of code
generation. (12.5)

Q9 Draw the Syntax Tree and DAG for the expression (a * b) + (c - d) * (a * b) + b (12.5)
***********
(please write your Exam Roll No.} Exam Roll No .


END TERM EXAMINATION
SIXTH SEMESTER MAY- JUNE 2017
Paper Code: ETCS-302 Subject: Compiler Design
Time: 3 Hours Maximum Marks: 75
Note: Attempt any five questions including Q.Nol which is compulsory.
Select one question from each unit.

Q1 Attempt any five parts:- (5x5=25)


(a) Explain the process of Bootstrapping in complier design with example.
(b) Differentiate between SDD and SDT with example.
(c) What is left recursion and left factoring? Explain each with example.
(d) What is back patching? Explain with example.
(e) What is the process of identifying basic blocks in code optimization phase?
(f) Differentiate between top-down and bottom-up parsers with example.
(g) Write a SDT for converting infix expression to post fix expression by taking
suitable example.

UNIT-I
Q2 (a) For the grammar given below:- (7.5)
E~TE'
E'~+TE'I E
T~FT'
T'~*FT'IE
F~(E)IID
Construct the LL(l) parsing table.
(b) Check whether the following grammar is LL(1) or not (5)
i. S~Ala, A~a
ii. S~aSAIE, A~cIE

Q3 (a) What do you mean by Handle? Check whether the grammar (5)
E~E+TIT,T~a is LR(O)or not
(b) Construct a LR (1) parsing table for (7.5)
S~AalbAcldclbda
A~d
UNIT-II
Q4 (a) Write an SDT to count the number of binary digits in a binary number.
(Hint: 1011 count is 4) (5)
(b) Differentiate between S-attributed and L-attributed SDT's. Write the steps to
create the SDT for any problem and write SDT for converting any number
from binary to decimal. (7.5)

Q5 (a) What do you mean by three address code? Explain how the three address
code is represented vis quadruples, triples and Indirect triples with
examples. (7.5)
(b) Write the three address code for: (5)
(i) while(a<5)do a:b+2)
(ii) -a(a+b)*(c+d)+(a+b+c)
UNIT-III
Q6 (a) What do you mean by symbol table? Write an example that shows how
different phases of complier interact with symbol table. (6)
(b) How the data is stored in symbol table for block and non-block structured
languages? (6.5)

Q7 (a) What are different types of errors that occurs during, lexical, syntactic and
semantic phase. (6)
P.T.O .
[-2-]

• (b) What are the different storage allocation strategies in the runtime
environment of the complier? (6.5)

UNIT-IV
Q8 (a) What do you mean by the term code optimization? What do you understand
by the term leader? Write algorithm to identify out the basic Blocks. (6)
(b) Identify the basic blocks in the following code and draw the DAG graph for
the same: (6.5)
maint]
{
inti=O,n=lO;
int aln];
while(i<=(n-l))

A[i]=i*i;
i=i+l;

return;

Q9 (a) What do you mean by peephole optimization? Explain with example. (6)
(b) What are the issues that occurs during the code generation process? (6.5)

**********

You might also like