Tribhuwan University

Institute of Science and Technology

2081

Bachelor Level / Third Year / Sixth Semester / Science

B.Sc in Computer Science and Information Technology (CSC376)

(Compiler Design and Construction)

Full Marks: 60

Pass Marks: 24

Time: 3 Hours

Candidates are required to give their answers in their own words as for as practicable.

The figures in the margin indicate full marks.

Section A

Long Answers Questions

Attempt any TWO questions.
[2*10=20]
1.
Give an example of reduce-reduce conflict. Construct the SLR parsing table for the following grammar.
E(L)aE \rightarrow (L) \mid a
LL,EEL \rightarrow L, E \mid E
[10]
2.
What are the significances of intermediate code? Differentiate between DAG and Syntax tree. Represent the instruction A = B + C - D * E + G using quadruple and triple. [10]
3.
Illustrate the concept of backpatching with an example. Convert the regular expression a(a + b)a# to DFA. [10]
Section B

Short Answers Questions

Attempt any Eight questions.
[8*5=40]
4.
Explain different phases of compiler in brief. [5]
5.
What types of information are stored in a symbol table? Discuss the activation record. [5]
6.
Compute the FIRST and FOLLOW of the non-terminals in the following grammar.
S(L)1S \rightarrow (L) \mid 1
LL;SεL \rightarrow L;S \mid \varepsilon
[5]
7.
Write the code generation algorithm for the instruction a = b op c. [5]
8.
Define core item. Compute the LR(1) item sets for the following grammar.
SAAS \rightarrow AA
AaAbA \rightarrow aA \mid b
[5]
9.
How do you represent recursion in an activation tree? Generate the three-address code for the following instruction: [5]
10.
What are the techniques for compiler optimization? Explain. [5]
11.
Describe the synthesized attribute and inherited attribute with an example. [5]
12.
What is a type expression? List the properties of LL(1) grammar. [5]