Professional Documents
Culture Documents
IT5502
IT5502
IT5502
B.E. / B. Tech / B. Arch (Full Time) - END SEMESTER EXAMINATIONS, JAN/FEB 2022
INFORMATION TECHNOLOGY
Fifth Semester (V)
IT5502 & Compiler Engineering
(Regulation 2019)
Time: 3hrs Max.Marks: 100
CO 1 Understand the concept of lexical analysis and construction of deterministic and non-
deterministic automata.
CO 4 Study programming language design, target machine design and run time environment
of compilers.
language.
Q. No Questions Marks CO BL
1 Draw a DFA for the language accepting strings ending with „10‟ 2 CO1 L5
over input alphabets ∑={0, 1}.
6 Eliminate left factors and left recursion in the following grammar 2 CO2 L3
for boolean expressions.
bexpr → bexpr or bterm∣ bterm
bterm → bterm and bfactor∣ bfactor
bfactor →not bfactor∣ (bexpr)∣ true∣ false
PART- B (5 x 13 = 65 Marks)
(Restrict to a maximum of 2 subdivisions)
Q. No Questions Marks CO BL
11 (a) (i) Construct NFA for the following regular expression and apply 9 CO1 L3
subset construction method to convert into DFA.
(a | b) ab (a|b)*
(ii) Construct the minimum-state DFA.for the DFA obtained in 11a)(i). 4 CO1 L3
OR
11 (b) (i) Construct DFA for the following regular expression without 9 CO1 L3
constructing NFA.
( a | b )* a b ( a | b )* #
(ii) Signed numbers are strings such as +1280, -31.67, +2.336E5 or - 4 CO1 L3
3.76E-3.
a) Give the regular definitions for the above mentioned strings.
b) Draw the state transition diagram for the signed numbers
12 (a) (i) Explain the phases of a Compiler and write down the output of 9 CO6 L2
each phase for the expression a := b + c * d / 3.
(ii) Identify the lexeme that make up the tokens in the following 4 CO1 L2
program segment. Indicate the corresponding token and pattern.
int checkPrimeNumber(int n)
{
int i, flag = 1, squareRoot;
squareRoot = sqrt(n);
for (i = 2; i <= squareRoot; ++i)
{
if (n % i == 0)
{
flag = 0;
break;
}
}
return flag;
}
OR
12 (b) (i) Write a Lex program that recognizes the tokens such as: if, then, 9 CO6 L4
else, while, relop, id and num.
(ii) Brief about Buffer pairs. What is the use of Sentinels in it? 4 CO1 L2
13 (a) (i) Devise predictive parser and show the parsing table for the 13 CO2 L3
following grammar:
S-> a | (R)
T-> S, T | S
R-> T
Check whether the given string “(a, (a,a))” belongs to the above
grammar.
OR
13 (b) (i) Construct a CLR parser for the following grammar: 13 CO2 L3
S →Ta | bTc |Xc | bXa
T→e
X→e
Parse the string “eaaaa” using the above grammar.
Check whether the given grammar is LALR(1)
14 (a) (i) Write the SDD with semantic actions for generating three address 9 CO3 L3
code for array references and translate the following assignment.
y = c[i][j] + d[i]+ a
(ii) With the proper L-attributed definition, draw a dependency graph 4 CO3 L3
for the following statement:
10 + 5 - (3 +7)
OR
14 (b) (i) Write the semantic actions for the translation of Expressions and 9 CO3 L3
translate the following expression to generate the three address
code using annotated parse tree:
x = a + b + (- d + - e)
(ii) Show the steps of constructing the syntax tree and DAG for the 4 CO3 L3
expression:
(a+b) - ((a+b) *(a-b)) + (a+b)
15 (a) (i) Explain how Peephole optimization can be applied to improve the 8 CO4 L2
intermediate code with an example for each of the characteristics
of optimization.
(ii) Generate intermediate code and target code for the expression 5 CO4 L4
x = (a-b) +(a+c)
OR
15 (b) (i) Assume the matrix entries are numbers that require 4 bytes, and 8 CO4 L4
that matrices are stored in row-major order.
Generate three address code and draw the flow graph for the
following code:
(ii) Optimize the three address code obtained from 15 (b)(i) by 5 CO4 L4
preserving the semantics of the original program.
PART- C (1 x 15 = 15 Marks)
(Q.No.16 is compulsory)
Q. No Questions Marks CO BL
16. (i) What is the intended use of short circuit code? 10 CO3 L5
Write the required Syntax Directed Definition and translate into
three address code for the statement:
(ii) Apply batckpatching to generate code for the same statement in 5 CO3 L3
one pass.