CT2353

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

2KTT/ARDR/ET – 12682

B. E. Sixth Semester (Computer Technology)/BECT_18


19_Rev_SOE_CT-201 Examination

Course Code : CT 2353 Course Name : Language Processors

Time : 2 Hours ] [ Max. Marks : 40


Instructions to Candidates :—
(1) Attempt any Four questions out of Six.
(2) All questions carry Ten marks.
(3) Assume suitable data wherever necessary.
(4) If question number written on answer book is incorrect, it will get zero marks.
(5) Due credit will be given to neatness and adequate dimensions.
(6) Illustrate your answers wherever necessary with the help of neat sketches.

1. (A) (A1) What is the theory and logic behind cross – compilation ? 4(CO1)
(A2) Apply Loop invariant computation optimization technique and eliminate
loop invariant computation from the given program fragment.
P=0
Q=1
do
P = P + X [I] * Y [I}
Q=Q+1
End
While Q <= 20 6(CO5)
OR

(B) (B1) Explain Fast Lexical Analyzer Generator in details and write a
flex program to count the words, lines, small letters, capital letters,
digits and special characters in a text file. 4(CO1)
(B2) Construct Directed Acyclic graph for the following piece of code
Repeat {
P = P + X [I] / Y [I]
Q=Q+1
}
Until Q > 100 6(CO5)

2KTT/ARDR/ET – 12682 Contd.


2. (A) (A1) Discuss the action taken by every phase of compiler on following
source code :
Pos = into + real *3.14
where Pos, into and real are the type of integer. 4(CO1)
(A2) Construct Recursive Descent parser for the following
Grammar :
EuE+T|T
TuT*F|F
F u id | (E) 6(CO2)
OR

(B) (B1) What is bootstrapping ? How is it used to build cross


compiler ? 4(CO2)
(B2) Find FIRST () and FOLLOW () for the following grammar :
E –> 10 * T | 5 + T , T –> PS , S –> QP | E , Q –> + | * , P –> a | b | c
Construct the parsing table for the above grammar and find out
whether it is LL (1) or not. 6(CO2)

3. (A) (A1) Construct LL (1) parsing table and check whether the given grammar
is LL (1) or not
SuA
A u aB | aC | Ad | Ae
B u bBC | f
Cug 4(CO2)
(A2) Obtain LALR parsing table for the grammar and show the stack
buffer content for string "id f id"
S u LfR / R
RuL
L u * R / id 6(CO2)
OR

(B) (B1) Construct the LL (1) Parsing Table for the following Grammar
EuE+T/T
TuT*F|F

2KTT/ARDR/ET – 12682 2 Contd.


F u (E) | id
W u id + id * id
Also show the stack content for w = id + id * id 4(CO2)
(B2) Construct the SLR Parsing Table for the following Grammar
S uAx B | B c
AuyA| z
BuxB|ε 6(CO2)

4. (A) (A1) Combine the states of the CLR parser and construct LALR parser.
S u aAd | bBd | aBe
Auc
Buc 5(CO2)
(A2) Consider the following expression P < Q or (R < S and T < U)
write translation scheme, three address code and annoted parse
tree. 5(CO3)

OR

(B) (B1) Suggest data structures that can be used to implement LL and
LR parser. 5(CO4)
(B2) Represent the expression a = (b + c) * (– c) in quadruple, Triple and
Indirect Triple Represenation. 5(CO3)

5. (A) (A1) Translate the following assignment statement to intermediate code


A [I , J] = B [I , J] + C [I + J]
Where bpw = 1 bytes
A is 3D of size 10 * 10 * 10
B is 2D of size 10 * 20
C is 1D of size 20 5(CO3)
(A2) Describe the data structure for symbol table and compare them.
5(CO4)

OR

(B) (B1) Write SDTS and generate TAC for the following statement, also
show the parse tree
for (i = 1 ; i <= 10 ; i = i + 1)
num = num + i ; 5(CO3)
2KTT/ARDR/ET – 12682 3 Contd.
(B2) What is an activation record ? Explain the meaning of each
entry in activation record. 5(CO4)

6. (A) (A1) What are data flow equations ? Using algorithm to compute IN
and OUT find the computation of IN and OUT. Program illustrating
definitions is as given below :
i=m–1
j=n
a = u1
do
i=i+1
j=j–1
if e1 then
a = u2
else
i = u3
while e2 6(CO5)
(A2) Explain phrase level error recovery method for LL parser by
taking an example. 4(CO4)

OR

(B) (B1) Why error handling module is very important in compiler


construction ? Also explain error detection in Lexical and Syntax
analysis phase. 6(CO4)
(B2) Label the following tree by labeling algorithm and determine the
number of register required.

4(CO5)

D
2KTT/ARDR/ET – 12682 4

You might also like