Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q621: A grammar must be __________ before being used in predictive parsing.
  • A: normalized
  • B: compiled
  • C: lexed
  • D: left-factored
View Answer
D

Q622: What is the purpose of left factoring a grammar?
  • A: To increase ambiguity
  • B: To eliminate left recursion
  • C: To simplify semantic analysis
  • D: To make grammar suitable for predictive parsing
View Answer
D

Q623: Which of the following grammars is NOT suitable for predictive parsing?
  • A: Left-factored grammar
  • B: Unambiguous grammar
  • C: Grammar with common prefixes
  • D: Grammar with distinct terminals
View Answer
C

Q624: The left-factoring transformation introduces a new non-terminal denoted by:
  • A: Y
  • B: Z
  • C: K
  • D: X
View Answer
B

Q625: If the original grammar is A → αβ1 | αβ2 | αβ3, the left-factored form of A is:
  • A: A → α | β1β2β3
  • B: A → β1β2β3 | α
  • C: A → αZ
  • D: B → αA
View Answer
C

Q626: Which is a correct set of productions for left-factored form of A → αβ1 | αβ2 | αβ3?
  • A: A → αZ, Z → β1 | β2 | β3
  • B: A → α | β1 | β2 | β3
  • C: A → β1Z, Z → α | β2 | β3
  • D: A → αZ, Z → α | β1 | β3
View Answer
A

Q627: Given the grammar: Factor → id | id[ExprList] | id(ExprList), which form is left-factored?
  • A: Factor → id | [ExprList] | (ExprList)
  • B: Factor → id Args; Args → [ExprList] | (ExprList) | ε
  • C: Factor → id + Args; Args → [ExprList]
  • D: Factor → ExprList | id | ε
View Answer
B

Q628: Which of the following makes a grammar non-LL(1)?
  • A: Use of ε in FIRST set
  • B: Overlapping FIRST sets for same non-terminal
  • C: Use of terminal in FOLLOW set
  • D: Use of distinct terminals
View Answer
B

Q629: Which of the following is TRUE about LL(1) grammar?
  • A: It can have common prefixes
  • B: It must be left-recursive
  • C: It must be left-factored
  • D: It can have multiple productions for the same terminal
View Answer
C

Q630: If two productions for a non-terminal start with the same terminal, what should be done?
  • A: Remove one
  • B: Use recursion
  • C: Left-factor the grammar
  • D: Ignore error
View Answer
C

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now