Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 25
Q781:
Fill in the blank: If γ begins with X, the transition from A→ α•Xη to A→ αX•η corresponds to recognizing ________.
A. X symbol
B. X dot
C. β production
D. Closure
Correct Answer: A
Chapter: 25
Q782:
Fill in the blank: An ε-transition in the NFA corresponds to adding items for productions of ________.
A. Non-terminals
B. Terminals
C. Lookahead symbols
D. Terminals and non-terminals
Correct Answer: A
Chapter: 26
Q783:
The initial DFA state I0 is computed as the _______ of the set containing [S → •E].
A. ε-closure
B. First set
C. Follow set
D. Closure
Correct Answer: A
Chapter: 26
Q784:
In LR(1) items, the dot '•' indicates the parser's position _______.
A. before the symbol after it
B. after the symbol before it
C. at the end of parsing
D. start of parsing
Correct Answer: A
Chapter: 26
Q785:
Closure of LR(1) items adds all productions of the _______ immediately after the dot.
A. non-terminal
B. terminal
C. start symbol
D. look-ahead symbol
Correct Answer: A
Chapter: 26
Q786:
Which function computes the new state after recognizing symbol X in state Ij?
A. goto
B. closure
C. reduce
D. shift
Correct Answer: A
Chapter: 26
Q787:
The collection of canonical LR(1) item sets is constructed by repeatedly applying _______ and goto operations.
A. closure
B. goto
C. reduce
D. shift
Correct Answer: A
Chapter: 26
Q788:
In the item [E → int•, $], the dot at the right end means the parser should _______.
A. reduce
B. shift
C. accept
D. error
Correct Answer: A
Chapter: 26
Q789:
State I2 = goto(I0, E) contains which of the following items?
A. [S → E•, $]
B. [E → int•, $]
C. [S → •E, $]
D. [E → •E+(E), $/+]
Correct Answer: A
Chapter: 26
Q790:
In state I2, the dot before '+' indicates the next expected symbol is _______.
A. +
B. int
C. (
D. )$
Correct Answer: A
Chapter: 26
Q791:
Item [E → E + • (E), $/+] means the parser is about to parse symbol _______.
A. (
B. +
C. int
D. )$
Correct Answer: A
Chapter: 26
Q792:
What is the purpose of the look-ahead symbol in LR(1) items?
A. Decide when to reduce
B. Indicate shift
C. End input
D. Start parsing
Correct Answer: A
Chapter: 26
Q793:
Which item indicates a completed production?
A. [E → int•, $]
B. [E → •int, $]
C. [S → •E, $]
D. [E → E + • (E), $/+]
Correct Answer: A
Chapter: 26
Q794:
In LR parsing, moving the dot past a symbol means a _______ operation.
A. shift
B. reduce
C. accept
D. error
Correct Answer: A
Chapter: 26
Q795:
The augmented grammar G' contains which start production?
A. S' → S
B. S → E
C. E → int
D. S' → E
Correct Answer: A
Chapter: 26
Q796:
The construction of LR(1) sets stops when _______.
A. no new states are added
B. accept state reached
C. error occurs
D. all states are processed
Correct Answer: A
Chapter: 26
Q797:
Which sets contain items with the dot at the end?
A. I1
B. I0
C. I2
D. I3
Correct Answer: A
Chapter: 26
Q798:
I4 = goto(I3, '(') results in items with the dot before which symbol?
A. E
B. int
C. +
D. )$
Correct Answer: A
Chapter: 26
Q799:
The symbol '+' in the production E → E + (E) is a _______.
A. terminal
B. non-terminal
C. epsilon
D. look-ahead
Correct Answer: A
Chapter: 26
Q800:
Closure uses look-ahead symbols derived from the _______ of remaining input after the dot.
A. FIRST set
B. FOLLOW set
C. LAST set
D. EMPTY set
Correct Answer: A

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now