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: 2075, syllabus wise question

S1
1.
Difference between compiler and interpreter. "Symbol table is necessary component of compiler". Justify this statement with examples. [6]
2.
What is activation record? Discuss the different activities performed by caller and callee during procedure call and return. [6]
S2
1.
List out the major tasks carried out in Lexical Analysis Phase. Convert the following NFA to DFA.
question image
[6]
2.
Differentiate between recursive descent and non-recursive predictive parsing method. Find first and follow of all the non-terminals in the following grammar.

$E \rightarrow TA; A \rightarrow +TA|\varepsilon; T \rightarrow FB; B \rightarrow *FB|\varepsilon; F \rightarrow (E)|id$
[6]
3.
Construct SLR parse table for the following grammar

$S \rightarrow E$

$E \rightarrow E+T|T$

$T \rightarrow T*F|F$

$F \rightarrow id$
[6]
4.
Define Syntax directed definition. Construct annotated parse tree for the input expression (5*3+2)*5 according to the following syntax directed definition.

$\[\begin{array}{|l|l|}\hline \text{Production} & \text{Semantic Rule} \\ \hline L \to E\text{n} & \text{Print } E.\text{val} \\ \hline E \to E_1 + T & E.\text{val} \to E_1.\text{val} + T.\text{val} \\ \hline E \to T & E.\text{val} \to T.\text{val} \\ \hline T \to T_1 * F & T.\text{val} \to T_1.\text{val} * F.\text{val} \\ \hline T \to F & T.\text{val} \to F.\text{val} \\ \hline F \to (E) & F.\text{val} \to (E.\text{val}) \\ \hline F \to \text{digit} & F.\text{val} \to \text{digit.lexval} \\ \hline \end{array}\]$
[6]
5.
Differentiate between static and dynamic type checking. How can we carry out type checking for the following expression using syntax-directed definition?

$S \rightarrow id = E$

$S \rightarrow if E then S1$

$S \rightarrow while E do S1$

$S \rightarrow S1; S2$
[6]
S3
1.
Define three address codes. write three address codes for

$S = do m = n + p while a < = b$
[6]
2.
Define code optimization. Discuss about any three code optimization techniques with example. [6]
3.
Discuss about the different factors affecting target code generation. [6]