Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 41
Q1081:
In flow-of-control translation, the statement S → begin L end results in S.nextlist being equal to ________.
A. L.nextlist
B. S1.nextlist
C. S2.nextlist
D. S.nextlist
Correct Answer: B
Chapter: 41
Q1082:
In the statement S → L1 ; M S, the semantic action backpatch(L1.nextlist, M.quad) means:
A. It links the nextlist of L1 to the quad at M
B. It starts a new statement
C. It clears the nextlist
D. It merges two nextlists
Correct Answer: A
Chapter: 41
Q1083:
The list-handling procedure used in backpatching maintains lists of ________.
A. quadruple indices
B. instruction addresses
C. variable names
D. constant values
Correct Answer: A
Chapter: 41
Q1084:
Which of the following is NOT a valid flow-of-control statement according to the grammar?
A. if E then S else S
B. for E do S
C. while E do S
D. break statement
Correct Answer: D
Chapter: 41
Q1085:
The nextQuad() function is used to:
A. return the index of the next quadruple
B. generate the next instruction
C. emit a goto statement
D. patch backpatch lists
Correct Answer: A
Chapter: 41
Q1086:
In the example if a < b or c < d and e < f then x = y+z else x = y-z, the E.truelist is ________.
A. [100,104]
B. [101,105]
C. [103,105]
D. [102,106]
Correct Answer: A
Chapter: 41
Q1087:
In the example, the quadruple 100 corresponds to:
A. if a < b goto _
B. if c < d goto _
C. if e < f goto _
D. goto _
Correct Answer: A
Chapter: 41
Q1088:
In the example, the semantic action backpatch([100,104],106) connects which part of the code?
A. The true lists of E to the start of then-part
B. The false lists of E to the else-part
C. The nextlist of S to the end
D. Initialization of M.quad
Correct Answer: A
Chapter: 41
Q1089:
The goto statement emitted by N → ε is used to:
A. Unconditionally jump to the next instruction
B. Conditional jump
C. Initialize loop counter
D. Merge nextlists
Correct Answer: A
Chapter: 41
Q1090:
In YACC semantic actions, %union is used to:
A. Define multiple attribute types
B. Store variables
C. Generate quadruples
D. Parse tokens
Correct Answer: A
Chapter: 41
Q1091:
The attribute S.nextlist for the statement S → if E then M1 S1 N else M2 S2 is:
A. merge(S1.nextlist, merge(N.nextlist, S2.nextlist))
B. merge(E.truelist, E.falselist)
C. E.truelist
D. E.falselist
Correct Answer: A
Chapter: 41
Q1092:
Fill in the blank: The quadruple for the assignment x = y + z is represented as ________.
A. x=y+z
B. goto _
C. if x=y+z
D. goto _
Correct Answer: A
Chapter: 41
Q1093:
Fill in the blank: The quadruple index for the first quad after if a < b is ________.
A. 100
B. 106
C. 108
D. 102
Correct Answer: A
Chapter: 41
Q1094:
Fill in the blank: The semantic action M → ε assigns ________ to M.quad.
A. nextQuad()
B. nil
D. -1
Correct Answer: A
Chapter: 41
Q1095:
Fill in the blank: The semantic action backpatch(E.truelist, M.quad) is used to patch ________.
A. true list of E
B. false list of E
C. nextlist of S
D. nextlist of N
Correct Answer: A
Chapter: 41
Q1096:
Fill in the blank: In the example, the statement 108 corresponds to ________.
A. x = y - z
B. goto _
C. if c < d
D. goto _
Correct Answer: A
Chapter: 41
Q1097:
Fill in the blank: The semantic action backpatch(E.falselist, M2.quad) connects the false list of E to the ________.
A. else part
B. then part
C. next part
D. next quad
Correct Answer: C
Chapter: 41
Q1098:
Fill in the blank: The list-handling procedures used in backpatching are similar to those used in ________.
A. Boolean expression translation
B. Memory allocation
C. Code optimization
D. Parsing syntax
Correct Answer: A
Chapter: 41
Q1099:
The semantic action backpatch([103,105],108) patches the false list to the quad index ________.
A. 108
B. 106
C. 102
D. 104
Correct Answer: A
Chapter: 41
Q1100:
Fill in the blank: The backpatching technique helps to resolve ________ in generated intermediate code.
A. jump targets
B. variable scopes
C. function calls
D. error handling
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now