Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Chapter: 40
Q1061:
Fill in the blank: The nextquad() function returns the _______.
A. Index of the next quadruple
B. Number of true labels
C. Current code line number
D. Number of variables
Correct Answer:
A
Chapter: 40
Q1062:
What are the two attributes propagated up the parse tree in boolean expressions?
A. truelist and falselist
B. variable list and label list
C. operator list and operand list
D. jump list and label list
Correct Answer:
A
Chapter: 40
Q1063:
Which production handles the 'or' operation in boolean expressions?
A. E → E1 or M E2
B. E → E1 and M E2
C. E → not E1
D. E → id1 relop id2
Correct Answer:
A
Chapter: 40
Q1064:
What is the purpose of the marker non-terminal M in syntax-directed translation?
A. Records the nextquad index
B. Generates a label
C. Deletes a list
D. Emits a jump
Correct Answer:
A
Chapter: 40
Q1065:
Which of the following quadruples corresponds to a conditional jump?
A. 100: if a < b goto _
B. 101: goto _
C. 105: goto _
D. 103: goto _
Correct Answer:
A
Chapter: 40
Q1066:
Fill in the blank: The backpatch(p, i) function _______.
A. Assigns target i to all quadruples in list p
B. Merges p and i
C. Deletes list p
D. Generates a new quadruple
Correct Answer:
A
Chapter: 40
Q1067:
What happens to the quadruple 101: goto _ after backpatch({101},102)?
A. It is patched to goto 102
B. It remains unchanged
C. It is deleted
D. It is merged with 102
Correct Answer:
A
Chapter: 40
Q1068:
Which attribute stores the quad index at which E2 begins in E → E1 or M E2?
A. M.quad
B. E.truelist
C. E.falselist
D. E1.truelist
Correct Answer:
A
Chapter: 40
Q1069:
Fill in the blank: The two lists used to track jump targets in boolean expressions are _______.
A. truelist and falselist
B. variablelist and labellist
C. operandlist and operatorlist
D. jumplist and calllist
Correct Answer:
A
Chapter: 40
Q1070:
In bottom-up parsing, the list E.falselist stores the quadruple indices of jumps for which condition?
A. False condition
B. True condition
C. No condition
D. All conditions
Correct Answer:
A
Chapter: 40
Q1071:
Which of the following best describes the meaning of backpatching?
A. Updating incomplete jump instructions with correct target addresses
B. Generating code for expressions
C. Parsing boolean expressions
D. Deleting quadruples
Correct Answer:
A
Chapter: 40
Q1072:
Fill in the blank: The quadruple 100: if a < b goto _ is generated during the reduction of _______.
A. a < b
B. E1 or M E2
C. E1 and M E2
D. not E1
Correct Answer:
A
Chapter: 40
Q1073:
What is the nextquad value used for in syntax-directed translation?
A. To mark the position for the next quadruple to be generated
B. To count the number of variables
C. To store the current token
D. To count errors
Correct Answer:
A
Chapter: 40
Q1074:
In the semantic rule E → E1 and M E2, what is the source of E.truelist?
A. E2.truelist
B. E1.truelist
C. M.quad
D. E.falselist
Correct Answer:
B
Chapter: 40
Q1075:
Fill in the blank: The last goto statements in the boolean expression evaluation will have their targets _______.
A. backpatched later
B. generated first
C. merged
D. ignored
Correct Answer:
A
Chapter: 40
Q1076:
Which of the following is NOT a synthesized attribute in the example?
A. truelist
B. labellist
C. falselist
D. quad indices
Correct Answer:
B
Chapter: 40
Q1077:
Fill in the blank: The attribute M.quad stores the _______.
A. Index of the first quadruple of E2
B. Label of the current token
C. Position of the parser
D. Index of last quadruple
Correct Answer:
A
Chapter: 41
Q1078:
In the production S → if E then M1 S1 N else M2 S2, the semantic action backpatches E.truelist to ________.
A. M1.quad
B. M2.quad
C. N.nextlist
D. S1.nextlist
Correct Answer:
A
Chapter: 41
Q1079:
What does the semantic action N → ε do in flow-of-control translation?
A. Initializes N.nextlist with nextQuad()
B. Backpatches E.falselist
C. Emits a conditional jump
D. Ends the statement
Correct Answer:
A
Chapter: 41
Q1080:
In the semantic action S → while M1 E do M2 S1, what does backpatch(S1.nextlist, M1.quad) achieve?
A. It patches the nextlist of S1 to the beginning of the loop
B. It ends the loop
C. It jumps to the exit point
D. It initializes M1.quad
Correct Answer:
A