Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 24
Q741:
The LR(1) item [S → •E, $] represents a configuration where S is expected followed by ________.
A. +
B. $
C. (
D. )
Correct Answer: B
Chapter: 24
Q742:
What does the closure procedure compute in LR(1) parser construction?
A. Transitions between states
B. Lookahead symbols
C. All items reachable from a given set
D. Grammar rules
Correct Answer: C
Chapter: 24
Q743:
In closure(s), if [X → α•Yβ, a] ∈ s and Y → γ is a production, then s is extended by ________.
A. [X → αY•β, a]
B. [Y → •γ, a]
C. [Y → •γ, b]
D. for all b ∈ FIRST(βa)
Correct Answer: D
Chapter: 24
Q744:
The function FIRST(βa) is used in closure to determine ________.
A. Lookahead symbols
B. Stack size
C. Possible next symbols
D. Number of productions
Correct Answer: C
Chapter: 24
Q745:
The initial set I0 of LR(1) items for the grammar S → E consists of how many items?
A. 1
B. 2
C. 3
D. 4
Correct Answer: C
Chapter: 24
Q746:
Which of the following productions is part of the closure of [S → •E, $] for the grammar S → E; E → E + (E) | int?
A. [E → E + (E) •, $]
B. [E → •E + (E), $]
C. [S → E •, $]
D. [E → •int, +]
Correct Answer: B
Chapter: 24
Q747:
If s changes in the closure procedure, what action is taken?
A. Stop and return s
B. Repeat the closure procedure
C. Discard s
D. Restart the parser
Correct Answer: B
Chapter: 24
Q748:
In LR(1), the lookahead symbol 'a' belongs to which set?
A. Non-terminals
B. Terminals
C. Productions
D. Stack symbols
Correct Answer: B
Chapter: 24
Q749:
The purpose of adding an augmented start symbol S is to ensure ________.
A. Unique goal symbol
B. More productions
C. Reduce ambiguity
D. Add states
Correct Answer: A
Chapter: 24
Q750:
The item [E → •int, $] in I0 means the parser expects ________ next with lookahead $.
A. int followed by $
B. int followed by +
C. int alone
D. $ alone
Correct Answer: A
Chapter: 24
Q751:
In closure(s), β in [X → α•Yβ, a] represents ________.
A. The part after Y
B. The part before α
C. The lookahead symbol
D. The entire right-hand side
Correct Answer: C
Chapter: 24
Q752:
Which of the following is NOT true about LR(1) items?
A. They include a dot indicating progress
B. They include a lookahead symbol
C. They represent entire parse trees
D. They correspond to parser states
Correct Answer: C
Chapter: 24
Q753:
The canonical collection is constructed by repeatedly applying ________.
A. Closure and Goto functions
B. Shift and Reduce
C. Parsing and Lexing
D. Stack operations
Correct Answer: A
Chapter: 24
Q754:
The lookahead symbol in LR(1) items helps the parser decide whether to ________.
A. Shift or reduce
B. Go to next state
C. Accept input
D. Restart parse
Correct Answer: A
Chapter: 24
Q755:
Fill in the blank: The initial core item of the first state I0 is ________.
A. [S → E•, $]
B. [S → •E, $]
C. [S → E, $]
D. [E → •int, $]
Correct Answer: B
Chapter: 24
Q756:
Fill in the blank: The procedure closure continues until the set s is ________.
A. Empty
B. Unchanged
C. Full
D. Reduced
Correct Answer: B
Chapter: 24
Q757:
Fill in the blank: FIRST(+(E)$) = ________.
A. +
B. E
C. $
D. (
Correct Answer: A
Chapter: 24
Q758:
What symbol does the parser use to represent the end of input?
A. $
B. #
C. *
D. @
Correct Answer: A
Chapter: 24
Q759:
In the closure procedure, for [E → •E+(E), $], the lookahead for new items is computed from ________.
A. FIRST(+(E)$)
B. FIRST(E)$
C. FIRST($)
D. FIRST(•E)$
Correct Answer: A
Chapter: 24
Q760:
Fill in the blank: In the augmented grammar, the start symbol S produces ________.
A. E
B. int
C. int + E
D. $
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now