Bachelors Level/Third Year/Sixth Semester/Science csit/sixth semester/compiler design and construction/syllabus wise questions

B.Sc Computer Science and Information Technology

Institute of Science and Technology, TU

Compiler Design and Construction (CSC376)

Year Asked: 2081.1, syllabus wise question

S1
1.
What are the roles of macros and preprocessor? Discuss about one pass and multi pass compiler. [5]
S2
1.
Create the LR(1) parsing table for following grammar.
SAAS \rightarrow AA
A0AA \rightarrow 0A
AεA \rightarrow \varepsilon
[10]
2.
Compute the FIRST and FOLLOW of all the non-terminals in following grammar.
SABS \rightarrow AB
A0A1AεA \rightarrow 0A' \mid 1A' \mid \varepsilon
ASSAεA' \rightarrow SSA' \mid \varepsilon
BAS1B \rightarrow AS \mid 1
[5]
3.
Construct the LL(1) parsing table for the following grammar.
SAS1CS \rightarrow AS1 \mid C
A0A \rightarrow 0
C2CεC \rightarrow 2C \mid \varepsilon
[5]
4.
Generate the LR(0) item sets for the following grammar.
ABBA \rightarrow BB
BbBaB \rightarrow bB \mid a
[5]
S3
1.
What are the operations performed in symbol table? Discuss about activation tree. [5]
2.
What is a symbol table? Discuss the general structure of an LR parser. [5]
S4
1.
Discuss about Directed Acyclic Graph with an example. Represent the expression A = (B + C) - (D - E) using 3AC, Quadruple and Triple. [10]
2.
Explain the optimization techniques for code optimization. Convert the following program to basic block and control flow.
M=A+BM = A + B
N=C+DN = C + D
IF (M>N)X=MN;\text{IF } (M > N) \rightarrow X = M - N;
ELSE E=M+N+X\text{ELSE } E = M + N + X
[10]
3.
Define explicit and implicit type conversion. Why do we need to check type of the system? Justify with an example. [5]
4.
Differentiate between synthesized and inherited attributes with example. [5]
5.
What are the advantages of intermediate code? How do you convert procedure call to 3AC? [5]