Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Chapter: 39
Q1041:
In the translation of the while statement, which label indicates the start of the loop?
A. L1
B. L2
C. L3
D. Lnext
Correct Answer:
A
Chapter: 39
Q1042:
What is the main difficulty in generating three-address code in one pass?
A. Unknown jump targets at generation time
B. Memory overflow
C. Parsing errors
D. Incorrect variable names
Correct Answer:
A
Chapter: 39
Q1043:
Which grammar rule uses the production E → ( E1 )?
A. Parenthesized boolean expression
B. Negation
C. Relational operation
D. Logical OR
Correct Answer:
D
Chapter: 39
Q1044:
What is the effect of the syntax-directed translation on E → true?
A. Generates a goto to E.true
B. Generates a goto to E.false
C. No code generated
D. Generates a false branch
Correct Answer:
A
Chapter: 39
Q1045:
Fill in the blank: In bottom-up parsing, the attribute quad stores the _______.
A. Index of the next quadruple
B. Number of true labels
C. Current code line number
D. Operator precedence
Correct Answer:
A
Chapter: 39
Q1046:
Which of the following is NOT part of boolean expression grammar?
A. E → id relop id
B. E → for loop
C. E → not E
D. E → true
Correct Answer:
B
Chapter: 39
Q1047:
What is the purpose of the gen() function in code generation?
A. Generates intermediate code or instructions
B. Parses input
C. Handles errors
D. Allocates memory
Correct Answer:
A
Chapter: 39
Q1048:
Fill in the blank: In syntax-directed translation, "||" denotes _______.
A. String concatenation
B. Logical OR
C. Bitwise OR
D. Arithmetic OR
Correct Answer:
B
Chapter: 39
Q1049:
What happens to E1.falselist in the production E → E1 or M E2?
A. It is backpatched to M.quad
B. It is merged with E2.truelist
C. It is assigned to E.truelist
D. It is ignored
Correct Answer:
A
Chapter: 39
Q1050:
In the example while statement translation, what does Lnext represent?
A. Next statement after the loop
B. Loop start label
C. False branch label
D. True branch label
Correct Answer:
A
Chapter: 39
Q1051:
Fill in the blank: The translation scheme uses _______ lists to track incomplete jumps for boolean expressions.
A. Truelist and falselist
B. Label and variable lists
C. True and false variables
D. Jump and call lists
Correct Answer:
A
Chapter: 39
Q1052:
What is the output of the backpatch(p, i) function?
A. Labels the gotos in list p with target i
B. Combines lists p and i
C. Deletes list p
D. Generates new code
Correct Answer:
A
Chapter: 39
Q1053:
In boolean expressions, what does E → false generate?
A. A goto to E.false
B. A goto to E.true
C. No code
D. A conditional jump
Correct Answer:
A
Chapter: 39
Q1054:
Fill in the blank: The conditional jump generated by E → id1 relop id2 has _______ targets.
A. Two
B. One
C. Zero
D. Three
Correct Answer:
A
Chapter: 40
Q1055:
In the production E → id1 relop id2, what does E.truelist represent?
A. A list containing the index of the next quadruple
B. A list of variable names
C. A list of labels
D. A list of operators
Correct Answer:
A
Chapter: 40
Q1056:
What is the function of makelist(nextquad()) in syntax-directed translation?
A. Creates a list with the current quadruple index
B. Deletes a list
C. Merges two lists
D. Generates a label
Correct Answer:
A
Chapter: 40
Q1057:
Which quadruple is generated first in the boolean expression a < b or c < d and e < f?
A. if a < b goto _
B. goto _
C. if c < d goto _
D. goto _
Correct Answer:
A
Chapter: 40
Q1058:
After reduction of c < d to E, what does E.falselist contain?
A. A list with quadruple index 103
B. A list with quadruple index 102
C. A list with quadruple index 104
D. A list with quadruple index 105
Correct Answer:
A
Chapter: 40
Q1059:
What does the semantic action backpatch(E1.truelist, M.quad) do?
A. Replaces the target of jumps in E1.truelist with M.quad
B. Merges two lists
C. Creates a new quadruple
D. Deletes E1.truelist
Correct Answer:
A
Chapter: 40
Q1060:
In the production E → E1 and M E2, what is the resulting E.falselist?
A. Merge of E1.falselist and E2.falselist
B. E2.falselist only
C. E1.falselist only
D. Empty list
Correct Answer:
A