CD Pyq
CD Pyq
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)
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.
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)
**********