Tribhuvan University
Bachelor of Science in Computer Science and Information Technology
Semester 6 · TU Board 2080
Course Title: Compiler Design and Construction (CSC365)
Full Marks: 60Pass Marks: 24Time: 3 hours
Candidates are required to give their answers in their own words as far as practicable. The figures in the margin indicate full marks.
Group A
Attempt any two questions.(2 × 10 = 20)
- 1.10
Differentiate between one-pass and multi-pass compiler. Construct the LL(1) parsing table for the following grammar.
S → ABCD
A → a | ε
B → b
C → 0 | ε
D → d | ε
- 2.10
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.10
Construct the LR(1) parsing table for the following grammar.
S → AaAb
A → BbBa
A → ε
B → ε
Answer comingAlso asked in 2081, 2076, 2075
Group B
Attempt any eight questions.(8 × 5 = 40)
- 4.5
Why code optimization is needed? Describe any two techniques for loop optimization.
Answer comingAlso asked in 2076
- 5.5
What is three-address code? How high level code is converted to three address code? Illustrate with an example.
- 6.5
What is activation tree? Define type checking system with examples.
- 7.5
What are the advantages of intermediate code? What types of information are provided by symbol table?
- 8.5
What is annotated parse tree? Define S-attributed grammar with an example.
- 9.5
Describe about syntax directed translation with an example.
- 10.5
Given the following grammar with SLR parsing table, test whether the string "int * (int + int)" will be accepted or rejected.
E -> T + E……….(1)
E -> T……….(2)
T -> int*T……….(3)
T -> int……….(4)
T -> (E)……….(5)
STATE
ACTION
GOTO
int(
)
$
E
T
1
S5
S4
2
3
2
ACC
3
S6
R2
R2
4
S5
S4
7
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.5
How do you recognize basic block? Discuss about the factors that affect code generator.
- 12.5
Find the FIRST and FOLLOW of all the non terminals in following grammar.
S → aAbCD | ε
A → SD | ε
C → Sa
D → aBD | ε
Answer comingAlso asked in 2081
— The End —