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.
ETA;A+TAε;TFB;BFBε;F(E)idE \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
SES \rightarrow E
EE+TTE \rightarrow E+T|T
TTFFT \rightarrow T*F|F
FidF \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.
ProductionSemantic RuleLEnPrint E.valEE1+TE.valE1.val+T.valETE.valT.valTT1FT.valT1.valF.valTFT.valF.valF(E)F.val(E.val)FdigitF.valdigit.lexval\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?
Sid=ES \rightarrow id = E
SifEthenS1S \rightarrow if E then S1
SwhileEdoS1S \rightarrow while E do S1
SS1;S2S \rightarrow S1; S2
[6]
S3
1.
Define three address codes. write three address codes for
S=dom=n+pwhilea<=bS = 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]