Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q811: The production F → id corresponds to which terminal in the FIRST set?
- A: id
- B: ×
- C: –
- D: S'
View Answer
A
Q812: In the example grammar, which rule corresponds to E → T – E?
- A: Rule 2
- B: Rule 3
- C: Rule 4
- D: Rule 5
View Answer
A
Q813: What does "closure" mean in the context of LR parser states?
- A: Generating all items from grammar rules
- B: Computing FIRST sets
- C: Finding FOLLOW sets
- D: Generating goto transitions
View Answer
A
Q814: Which of the following is TRUE about the goto function in LR parsing?
- A: It transitions between parser states using terminal symbols
- B: It transitions between parser states using non-terminal symbols
- C: It reduces productions
- D: It accepts input strings
View Answer
B
Q815: The canonical collection of LR(1) items is constructed starting from:
- A: Closure of [S' → •E, $]
- B: Closure of [E → •T, $]
- C: Closure of [T → •F, $]
- D: Closure of [F → •id, $]
View Answer
A
Q816: What action does the parser take for Action[0, id] according to the LR table example?
- A: Shift 4
- B: Reduce 6
- C: Accept
- D: Shift 3
View Answer
A
Q817: In the LR table, Action[2, –] is:
- A: Shift 5
- B: Reduce 3
- C: Shift 3
- D: Reduce 6
View Answer
A
Q818: Action[1, $] in the LR parsing table is:
- A: Accept
- B: Reduce 2
- C: Shift 4
- D: Error
View Answer
A
Q819: Which states have the action "reduce 6" in the example LR table?
- A: States 4, 5, and 6
- B: State 4 only
- C: State 3 and 4
- D: State 1 only
View Answer
A
Q820: The rule "reduce 3" corresponds to which production in the example?
- A: E → T
- B: T → F
- C: F → id
- D: E → T – E
View Answer
A