LearnCSIT
Tribhuwan University
Institute of Science and Technology
2079
Bachelor Level/ sixth Semester/ Science
B.Sc.CSIT
Compiler Design and Construction
Full Marks: 60
Pass Marks: 24
Time: 3 hours
Candidates are required to give their answer in their own words as far as practicable.
The figures in the margin indicate full marks.
Section A
Attempt any TWO questions
1.
Explain the role of Lexical Analyzer. Define Regular Expression. Convert the 1.(0+1)*.0 to DFA directly. (3+1+6)
2.
What do you understand by top down parsing? Construct an LL(1) parse table for the following grammar. (2+8)
A→BC
C→bBC | e
B→ED
D→cED | e
E→(A) | a
3.
Write the advantages of Intermediate Code Generation. Explain different types of intermediate coded representation methods with example. (10)
Section B
Attempt any EIGHT questions
4.
Draw block diagram with phases of compiler and explain any two phases.
5.
What is symbol table? What information is stored in symbol table? Explain.
6.
Given a left recursion grammar. Remove left recursion.
A→A+A | A*A | (B) | x
B→B-B | B/B | y | C
C→xy
7.
What is a handle in shift reduce parsing. Perform shift reduce parsing of string w=(a+a*a) for given grammar
S→S+S | S*S | (S) | a
8.
Write syntax directed definition for type checking in the following code.
S→id = E
S→if E then S1
S→while E do S2
9.
Define three address codes. Write three address code for
A-> do x=y*y+z while a < b
10.
List out the advantages and disadvantages of STATIC run time storage management.
11.
Discuss how constant propagation is different from copy propagation in code optimization.
12.
Define basic block and control flow graph with example.