Explore topic-wise MCQs in Compilers.

This section includes 4 Mcqs, each offering curated multiple-choice questions to sharpen your Compilers knowledge and support exam preparation. Choose a topic below to get started.

1.

Choose the equivalent prefix form of the following expression(a + (b − c))* ((d − e)/(f + g − h))

A. * +a − bc /− de − +fgh
B. * +a −bc − /de − +fgh
C. * +a − bc /− ed + −fgh
D. * +ab − c /− ed + −fgh
Answer» B. * +a −bc − /de − +fgh
2.

Consider the following grammar and the semantic actions to support the inherited type declaration attributes. Let X1, X2, X3, X4, X5 and X6 be the placeholders for the non-terminals D, T, L or L1 in the following table:Production ruleSemantic actionD → T LX1.type = X2.typeT → intT.type = intT → floatT.type = floatL → L1, idX3.type = X4.typeaddType(id.entry, X5.type)L → idaddType(id.entry, X6.type) Which one of the following are the appropriate choices for X1, X2, X3 and X4?

A. X1 = L, X2 = T, X3 = L1, X4 = L
B. X1 = T, X2 = L, X3 = L1, X4 = T
C. X1 = L, X2 = L, X3 = L1, X4 = T
D. X1 = T, X2 = L, X3 = T, X4 = L1
Answer» B. X1 = T, X2 = L, X3 = L1, X4 = T
3.

Convert the pre-fix expression to in-fix--*+ABC*DE+FG

A. (A - B)*C+(D*E)-(F+G)
B. (A+B)*C-(D-E)*(F-G)
C. (A+B-C)*(D-E)*(F+G)
D. (A+B)*C - (D*E)-(F+G)
Answer» E.
4.

Consider the productions A → PQ and A → XY. Each of the five non-terminals A, P, Q, X and Y has two attributes: s is a synthesized attribute, and i is an inherited attribute. Consider the following rules.Rule 1: P.i = A.i + 2, Q.i = P.i + A.i, and A.s = P.s + Q.sRule 2: X.i = A.i + Y.s and Y.i = X.s + A.iWhich one of the following is TRUE?

A. Both Rule 1 and Rule 2 are L-attributed.
B. Only Rule 1 is L-attributed.
C. Only Rule 2 is L-attributed.
D. Neither Rule 1 nor Rule 2 is L-attributed.
Answer» C. Only Rule 2 is L-attributed.