Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q871: LALR(1) parsing tables are constructed by merging states that have the same _______.
- A: core
- B: lookahead
- C: terminal
- D: action
View Answer
A
Q872: Which of the following best describes LALR(1) languages?
- A: Efficiency hack on LR languages
- B: Completely new parsing approach
- C: More ambiguous languages
- D: Only used for natural languages
View Answer
A
Q873: The algorithm to generate LALR(1) DFA involves repeatedly merging states with the same _______.
- A: core
- B: lookahead
- C: terminals
- D: stack
View Answer
A
Q874: In shift/reduce conflict with E → E × E and E → E + E, the usual resolution is to _______.
- A: shift for ×, reduce for +
- B: reduce for ×, shift for +
- C: shift for both
- D: reduce for both
View Answer
A
Q875: Fill in the blank: The size of an LR(1) parsing table is usually ______ compared to simpler parsers.
- A: very large
- B: very small
- C: always fixed
- D: constant
View Answer
A
Q876: The lookahead terminal in an LR(1) item helps to decide:
- A: When to reduce
- B: When to shift
- C: When to accept
- D: When to scan
View Answer
A
Q877: In the given DFA states { [X → α•, a], [Y → β•, c] } and { [X → α•, b], [Y → β•, d] }, merging results in:
- A: { [X → α•, a/b], [Y → β•, c/d] }
- B: { [X → α•, a], [Y → β•, d] }
- C: { [X → α•, c], [Y → β•, b] }
- D: { [X → α•, b/c], [Y → β•, a/d] }
View Answer
A
Q878: Which of the following is NOT true about LALR(1) parsers?
- A: They have smaller tables than LR(1)
- B: They merge states with the same core
- C: They handle all ambiguous grammars
- D: They are used in many programming languages
View Answer
C
Q879: Fill in the blank: The conflict where the parser cannot decide between two possible reductions is called ______.
- A: reduce/reduce conflict
- B: shift/reduce conflict
- C: shift/shift conflict
- D: accept/reduce conflict
View Answer
A
Q880: In LALR(1) parsing, merging states reduces the number of states and hence ______.
- A: reduces table size
- B: increases parsing time
- C: causes errors
- D: removes all conflicts
View Answer
A