Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q861: The "$" token in LR(1) parsing indicates:
- A: End of input
- B: Start of input
- C: Any terminal
- D: Any non-terminal
View Answer
A
Q862: Fill in the blank: The LR(1) parser stack initially contains _______ and 0.
- A: dummy
- B: token
- C: EOF
- D: start symbol
View Answer
A
Q863: What is the usual parser action when the state contains both [X → α•aβ, b] and [Y → γ•, a]?
- A: Shift
- B: Reduce
- C: Accept
- D: Error
View Answer
A
Q864: The action "accept" in the LR(1) parser means:
- A: Parsing is complete successfully
- B: Continue parsing
- C: Reduce by start symbol
- D: Report an error
View Answer
A
Q865: A shift/reduce conflict occurs when the parser has to decide between _______ and _______ on the same input.
- A: shifting and reducing
- B: accepting and rejecting
- C: scanning and shifting
- D: reducing and accepting
View Answer
A
Q866: Which conflict occurs when a DFA state has two different productions both ending at the same input?
- A: Shift/Reduce conflict
- B: Reduce/Reduce conflict
- C: Syntax error
- D: Lexical ambiguity
View Answer
B
Q867: Reduce/Reduce conflicts usually occur because of what?
- A: Ambiguous grammar
- B: Missing tokens
- C: Wrong token
- D: Infinite recursion
View Answer
A
Q868: The core of an LR(1) item set consists of:
- A: Items without lookahead terminals
- B: Items with all lookaheads
- C: Only terminals
- D: Only non-terminals
View Answer
A
Q869: What is the main advantage of LALR(1) parsing over LR(1) parsing?
- A: Smaller parsing table
- B: More accurate parsing
- C: Supports more grammars
- D: Easier to implement
View Answer
A
Q870: The LALR(1) parser has roughly ______ the number of states compared to LR(1).
- A: 10 times fewer
- B: 2 times more
- C: Same number
- D: 100 times fewer
View Answer
A