Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 26
Q801:
Which is NOT part of an LR(1) item?
A. Parsing stack
B. Production
C. Dot symbol
D. Look-ahead symbol
Correct Answer: A
Chapter: 26
Q802:
What does goto(Ij, X) return?
A. Set of items after recognizing X from Ij
B. Reduced grammar
C. Set of terminals
D. New grammar
Correct Answer: A
Chapter: 26
Q803:
The LR(1) transition diagram is a _______.
A. DFA
B. NFA
C. PDA
D. Turing machine
Correct Answer: A
Chapter: 26
Q804:
In LR parsing, the stack stores _______.
A. States and symbols
B. Only terminals
C. Only non-terminals
D. Look-ahead symbols
Correct Answer: A
Chapter: 26
Q805:
Transition from I4 to I5 on 'int' leads to item _______.
A. [E → int•, )/+]
B. [E → •int, $/+]
C. [E → E + (• E), $/+]
D. [S → E•, $]
Correct Answer: A
Chapter: 27
Q806:
What is the initial state in the LR parser construction?
A. The state containing [S' → •S, $]
B. The state containing [E → •T, $]
C. The state containing [T → •F, $]
D. The state containing [F → •id, $]
Correct Answer: A
Chapter: 27
Q807:
Which of the following is NOT a parsing action in LR(1) table?
A. Shift
B. Reduce
C. Accept
D. Reject
Correct Answer: D
Chapter: 27
Q808:
The symbol '$' in the parsing table denotes:
A. End of file marker
B. Start of input
C. Any terminal symbol
D. Non-terminal symbol
Correct Answer: A
Chapter: 27
Q809:
The rule for setting Goto[i, A] in the LR table is based on:
A. Terminal symbols
B. Non-terminal symbols
C. Grammar rules
D. Parser states
Correct Answer: B
Chapter: 27
Q810:
The set CC = {I0, I1, I2, ..., In} in LR parsing represents:
A. Parser actions
B. Parser states
C. Grammar productions
D. Input symbols
Correct Answer: B
Chapter: 27
Q811:
The production F → id corresponds to which terminal in the FIRST set?
A. id
B. ×
C. –
D. S'
Correct Answer: A
Chapter: 27
Q812:
In the example grammar, which rule corresponds to E → T – E?
A. Rule 2
B. Rule 3
C. Rule 4
D. Rule 5
Correct Answer: A
Chapter: 27
Q813:
What does "closure" mean in the context of LR parser states?
A. Generating all items from grammar rules
B. Computing FIRST sets
C. Finding FOLLOW sets
D. Generating goto transitions
Correct Answer: A
Chapter: 27
Q814:
Which of the following is TRUE about the goto function in LR parsing?
A. It transitions between parser states using terminal symbols
B. It transitions between parser states using non-terminal symbols
C. It reduces productions
D. It accepts input strings
Correct Answer: B
Chapter: 27
Q815:
The canonical collection of LR(1) items is constructed starting from:
A. Closure of [S' → •E, $]
B. Closure of [E → •T, $]
C. Closure of [T → •F, $]
D. Closure of [F → •id, $]
Correct Answer: A
Chapter: 27
Q816:
What action does the parser take for Action[0, id] according to the LR table example?
A. Shift 4
B. Reduce 6
C. Accept
D. Shift 3
Correct Answer: A
Chapter: 27
Q817:
In the LR table, Action[2, –] is:
A. Shift 5
B. Reduce 3
C. Shift 3
D. Reduce 6
Correct Answer: A
Chapter: 27
Q818:
Action[1, $] in the LR parsing table is:
A. Accept
B. Reduce 2
C. Shift 4
D. Error
Correct Answer: A
Chapter: 27
Q819:
Which states have the action "reduce 6" in the example LR table?
A. States 4, 5, and 6
B. State 4 only
C. State 3 and 4
D. State 1 only
Correct Answer: A
Chapter: 27
Q820:
The rule "reduce 3" corresponds to which production in the example?
A. E → T
B. T → F
C. F → id
D. E → T – E
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now