Tribhuwan University

Institute of Science and Technology

2078

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.
List out the tasks performed by Lexical Analyser. Define DFA. Convert the Regular Expression (a+b)a(a+b)(a+b)^*a(a+b) to DFA directly. [10]
2.
Differentiate between LR(0) and LR(1) algorithm. Construct LR(1) parse table of the following grammar.
SAAS \rightarrow AA
AaAbA \rightarrow aA | b
[10]
3.
Define type checking. Differentiate between type casting and coercion? Write SDT to carry out type checking for the following expression.
EnEEE==EE[E]EE \rightarrow n \mid E * E \mid E == E \mid E[E] \mid E \uparrow
[10]
Section B

Short Answers Questions

Attempt any Eight questions.
[8*5=40]
4.
Define compiler and differentiate it with an interpreter. [5]
5.
What are the typical entries made in symbol table? Explain. [5]
6.
Define Left recursive grammar. Remove left recursion from the following grammar.
SSBCaS \rightarrow SB | Ca
BBbcB \rightarrow Bb | c
CaBaC \rightarrow aB | a
[5]
7.
What are the disadvantages of shift reduce parsing. Perform shift reduce parsing of string w = (x-x). (x/x) for given grammar.
EEEE/E(E)xE \rightarrow E-E | E/E | (E) | x
[5]
8.
Define attribute grammar with example of inherited and synthesized attributes. [5]
9.
Define three address codes. Write down Quadruples for:
a=b(c+d)/ea = -b*(c+d)/e
[5]
10.
List out different types of run time storage management techniques. Explain any one of them. [5]
11.
What is the advantages of code optimization? Explain about dead-code elimination. [5]
12.
Explain about the factors affecting target code generation. [5]