LearnCSIT
Tribhuwan University
Institute of Science and Technology
2080
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.
Differentiate between one pass and multi pass compiler. Construct the LL(1) parsing table for the following grammar. (2+8)
S→ABCD
A→a | e
B→b
C→0 | e
D→d | e
2.
How does Lexical Analyzer recognize a token? Give an example to make it clear. Convert the regular expression a(a+b)(b+c)*a# to DFA. (3+7)
3.
Construct the LR(1) parsing table for the following grammar. (10)
S→AaAb
S→BbBa
A→e
B→e
Section B
Attempt any EIGHT questions
4.
Why code optimization is needed? Describe any two techniques for loop optimization. (3+2)
5.
What is three-address code? How high level code is converted to three-address code? Illustrate with an example. (2+3)
6.
What is activation tree? Define type checking system with examples. (2+3)
7.
What are the advantages of intermediate code? What types of information are provided by symbol table? (2+3)
8.
What is annotated parse tree? Define S-attributed grammar with an example. (2+3)
9.
Describe about syntax directed translation with an example. (5)
10.
Given the following grammar with SLR parsing table, test whether the string "int * (int + int)" will be accepted or rejected. (5)
E-> T + E (1)
E-> T (2)
T-> int * T (3)
T-> int (4)
T-> (E) (5)
S
ACTION
GOTO
int
*
+
(
)
$
E
T
1
S5
S4
2
3
2
Acc
3
S6
R2
R2
4
S5
S4
9
3
5
S8
R4
R4
R4
6
S5
S4
9
3
7
S10
8
S5
S4
11
9
R1
R1
10
R5
R5
R5
11
R3
R3
R3
11.
How do you recognize basic block? Discuss about the factors that affect code generator. (2+3)
12.
Find the FIRST and FOLLOW of all the non terminals in the following grammar. (5)
S→aAbCD | e
A→SD | e
C→Sa
D→aBD | e