Tribhuvan University
Institute of Science and Technology
2081(new)
Bachelor Level / sixth-semester / Science
Computer Science and Information Technology( CSC365 )
Compiler Design and Construction
Full Marks: 60 + 20 + 20
Pass Marks: 24 + 8 + 8
Time: 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.
SECTION A
Attempt any TWO question.
Discuss about Directed Acyclic Graph with an example. Represent the expression A = (B + C) – (D – E) using 3AC, Quadruple and Triple.
Create the LR(1) parsing table for following grammar.
S → AA
A → 0A
A → ε
Explain the optimization techniques for code optimization. Convert the following program to basic block and control flow.
M = A + B
N = C + D
IF (M > N)
X = M – N;
ELSE
E = M + N + X
SECTION B
Attempt any EIGHT question.
Compute the FIRST and FOLLOW of all the non-terminals in following grammar.
S → AB
A → 0A’ | 1A’ | ε
A’ → SSA’ | ε
B → AS | 1
What are the operations performed in symbol table? Discuss about activation tree.
What are the roles of macros and preprocessor? Discuss about one pass and multi pass compiler.
Define explicit and implicit type conversion. Why do we need to check type of the system? Justify with an example.
Differentiate between synthesized and inherited attributes with example.
Construct the LL(1) parsing table for the following grammar.
S → AS1 | C
A → 0
C → 2C | ε
What are the advantages of intermediate code? How do you convert procedure call to 3AC?
What is a symbol table? Discuss the general structure of an LR parser.
Generate the LR(0) item sets for the following grammar.
A → BB
B → bB | a