0% found this document useful (0 votes)
12 views2 pages

Theory of Computation and Compilers 20CIC07

Uploaded by

sjjjjadhav
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)
12 views2 pages

Theory of Computation and Compilers 20CIC07

Uploaded by

sjjjjadhav
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/ 2

Code No.

: 20CIC07
CHAITANYA BHARATHI INSTITUTE OF TECHNOLOGY (Autonomous)
B.E. (CSM, CET) VI Sem (Main & Backlog) Examination May – June 2024
Theory of Computation and Compilers
Time: 3 Hours Max Marks: 60
Note: Answer ALL questions from Part-A & Part –B (Internal Choice) at one place in the
same order
Part - A
(5Q X 3M = 15 Marks)
M CO BT
1 Write all the lexemes that make up tokens in the C language function (3) 1 3
int MAX(int i, int j){
if( i>j)
return i;
else
return j;
}
2 Define CFG. Identify the language generated by the CFG (3) 3 1
S→aSb
S→ab
3 Differentiate Synthesized and Inherited Attributes. (3) 4 4
4 Discuss briefly about code motion technique of loop optimization. (3) 5 1
5 How to identify leaders in a program? (3) 5 2

Part – B
(5Q X 9M = 45 Marks)
M CO BT
6 (a) Give NFA with four states equivalent to the regular expression (5) 1 3
(01 +011 + 0111)*. Convert this automaton to an equivalent DFA.
(b) Discuss how Finite Automata is used to recognize tokens and perform (4) 1 2
lexical analysis with an example.
(OR)
7 (a) Explain the different phases of a compiler, showing the output of each (5) 2 3
phase using the example for the statement:
x=(a+b) * (c+d)
(b) Explain how regular expressions are used in lexical analysis phase with (4) 2 2
examples.

8 (a) Construct sets of LR(0) items for the following ambiguous grammar (5) 3 3
E→ E+E | E*E | (E) | id. Construct the SLR table for the given grammar.
(b) Is the following grammar ambiguous? Justify your answer with (4) 3 4
examples of different parse trees for the same string.
S → aSb | SS | ε
(OR)

Page 1 of 2
Code No.: 20CIC07
9 (a) Remove the left recursion for the following grammar and also find (5) 3 3
FIRST’s and FOLLOW’s.
E→E + T | T
T→T * F | F
F → (E)/id
(b) Write the steps/algorithm to construct the predictive parser table and (4) 3 2
explain with an example.

10 (a) Translate the following expression: (5) 4 3


(a + b) * (c + d) + (a + b + c) into
i) Quadruples ii) Triples
(b) Compare and contrast S-Attributed definitions with L-Attributed (4) 4 2
definitions.
(OR)
11 (a) Explain symbol table organization using hash tables? With an example (5) 2 2
show the symbol table organization for block structured language.
(b) Give syntax directed translation scheme for simple desk calculator. (4) 4 1

12 (a) Given the following code, construct the control flow graph and perform (5) 5 3
live variable analysis:
a = 3;
b = a + 2;
if (b > 4) { c = b; }
else { c = a; }
d = c + 1;
(b) What is Flow-Graph? Explain how a given program can be converted (4) 5 2
into Flow Graph?
(OR)
13 (a) Construct a DAG for the following program code: (5) 5 3
x=y*z
w=p+y
y=y*z
p=w-x
(b) Explain the following with an example (4) 5 2
i) Constant Propagation
ii) Strength Reduction

14 (a) Explain Peephole Optimization and its various techniques. (5) 5 2


(b) Explain briefly about generic code generation algorithm. (4) 5 2
(OR)
15 (a) Explain error recovery in LR Parsing. (5) 6 2
(b) Explain Global Data Flow analysis with necessary equations. (4) 5 2
******

Page 2 of 2

You might also like