Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q831: Which production is reduced at state 3 on input $ according to the LR table?
  • A: T → F
  • B: F → id
  • C: E → T – E
  • D: E → T
View Answer
A

Q832: Which is the correct goto entry for goto(0, E) in the example?
  • A: 1
  • B: 2
  • C: 3
  • D: 4
View Answer
A

Q833: In the LR parsing example, the state I4 contains which items?
  • A: [F → id•, $], [F → id•, –], [F → id•, ×]
  • B: [E → T•, $], [E → T• – E, $]
  • C: [T → F• ×T, $], [T → F•, $]
  • D: [S' → •E, $]
View Answer
A

Q834: What is the role of the scanner in LR parsing?
  • A: Tokenize the input string
  • B: Build the parsing table
  • C: Generate grammar rules
  • D: Apply reduce actions
View Answer
A

Q835: Which of the following best describes the 'shift' operation in LR parsing?
  • A: Move the dot one symbol to the right
  • B: Move to the next input token and push it to the stack
  • C: Pop from stack
  • D: Accept input
View Answer
B

Q836: Fill in the blank: In LR parsing, the stack keeps track of states and ________.
  • A: grammar symbols
  • B: input tokens
  • C: errors
  • D: productions
View Answer
A

Q837: In the example, which action corresponds to Action[5, id]?
  • A: Shift 4
  • B: Reduce 6
  • C: Accept
  • D: Shift 5
View Answer
A

Q838: Fill in the blank: The set I0 in the example contains items derived by ________.
  • A: Closure
  • B: goto
  • C: Reduce
  • D: Shift
View Answer
A

Q839: What is the purpose of "closure" in LR parser state construction?
  • A: Add all possible items reachable from a non-terminal
  • B: Add only items with terminal symbols
  • C: Ignore lookahead symbols
  • D: Only add initial item
View Answer
A

Q840: In the LR table, what does "acc" mean?
  • A: Accept
  • B: Error
  • C: Shift
  • D: Reduce
View Answer
A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now