Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q821: In the LR parsing example, what is the purpose of the stack?
  • A: Store grammar rules
  • B: Store input symbols
  • C: Store parser states and grammar symbols
  • D: Store input string
View Answer
A

Q822: What is the input string encoded by the scanner in the example?
  • A: id – id × id $
  • B: id + id × id $
  • C: id – id + id $
  • D: id × id – id $
View Answer
A

Q823: In the parsing stack, what does "s4" signify?
  • A: Shift and go to state 4
  • B: Reduce by rule 4
  • C: Accept state
  • D: Shift and go to state 3
View Answer
A

Q824: Which of these is a valid reduce action in the example?
  • A: Action[7, $] ← reduce 2
  • B: Action[1, id] ← reduce 3
  • C: Action[0, id] ← reduce 6
  • D: Action[3, id] ← reduce 5
View Answer
A

Q825: Fill in the blank: The LR parsing table uses ________ sets to build states and actions.
  • A: FOLLOW
  • B: FIRST
  • C: LALR
  • D: CLOSURE
View Answer
B

Q826: Fill in the blank: The "accept" action is set when the item ________ is present in the state.
  • A: [S' → S•, $]
  • B: [E → T•, $]
  • C: [T → F•, $]
  • D: [F → id•, $]
View Answer
A

Q827: Fill in the blank: In the grammar example, the symbol "×" belongs to the FIRST set of ________.
  • A: id
  • B: ×
  • C: –
  • D: F
View Answer
A

Q828: What is the reduce action for Action[8, –] in the example?
  • A: Reduce 4
  • B: Reduce 5
  • C: Shift 6
  • D: Accept
View Answer
A

Q829: When does the LR parser shift the input symbol?
  • A: When the item has a dot before a terminal symbol
  • B: When the item has a dot at the end
  • C: When the item has a dot before a non-terminal symbol
  • D: When the item is the accept item
View Answer
A

Q830: Fill in the blank: The action "r5" means ________.
  • A: Reduce by production 5
  • B: Shift 5
  • C: Accept
  • D: Reject
View Answer
A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now