Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 21
Q661:
A handle is always a substring that matches the _______ of a production rule.
A. Left-hand side
B. Entire production
C. Right-hand side
D. First terminal
Correct Answer: C
Chapter: 21
Q662:
What is the role of the stack in bottom-up parsing?
A. To store terminals only
B. To hold the input buffer
C. To maintain the upper frontier
D. To hold error messages
Correct Answer: C
Chapter: 21
Q663:
Handle pruning refers to repeatedly locating handles and _______.
A. Deleting them
B. Shifting them
C. Reducing them
D. Pushing them back
Correct Answer: C
Chapter: 21
Q664:
Why does the bottom-up parser use a stack?
A. To manage memory efficiently
B. To represent the grammar
C. To track terminals only
D. To avoid errors
Correct Answer: A
Chapter: 21
Q665:
The stack ensures that all handles occur with their _______ at the top.
A. Left end
B. Right end
C. Middle
D. End of input
Correct Answer: B
Chapter: 21
Q666:
Which of the following simplifies space management in bottom-up parsing?
A. Buffers
B. Tokens
C. Grammar rules
D. Stacks
Correct Answer: D
Chapter: 21
Q667:
The algorithm begins by pushing _______ onto the stack.
A. ►
B. $
C. Top symbol
D. Start symbol
Correct Answer: B
Chapter: 21
Q668:
What is the stopping condition for the shift-reduce parsing algorithm?
A. Input is empty and stack has $
B. Input has only terminals
C. Input is reduced to start symbol and stack has Goal on top of $
D. Stack is full
Correct Answer: C
Chapter: 21
Q669:
In the algorithm, what is sym assigned to?
A. $
B. NextToken()
C. Top of stack
D. Last terminal
Correct Answer: B
Chapter: 21
Q670:
What happens if there is no handle and no input?
A. Parsing continues
B. Shift occurs
C. Reduce occurs
D. Error is reported and halt
Correct Answer: D
Chapter: 21
Q671:
The handle in bottom-up parsing corresponds to a step in _______.
A. Leftmost derivation
B. Rightmost derivation
C. Center derivation
D. Topmost derivation
Correct Answer: B
Chapter: 21
Q672:
In bottom-up parsing, the symbol ‘$’ indicates _______.
A. End of input
B. Start of stack
C. Start symbol
D. Error marker
Correct Answer: A
Chapter: 21
Q673:
In handle pruning, what is pruned from the parse tree?
A. The root
B. The leaves
C. The matched handle
D. The unmatched terminal
Correct Answer: C
Chapter: 21
Q674:
Which of the following actions is not part of bottom-up parsing?
A. Shift
B. Reduce
C. Error detection
D. Derive new grammar rules
Correct Answer: D
Chapter: 21
Q675:
If a handle is found on top of the stack, what happens next?
A. The handle is ignored
B. The handle is pushed again
C. The handle is reduced
D. The handle is popped and ignored
Correct Answer: C
Chapter: 21
Q676:
The parsing algorithm will continue until ______.
A. Sym is $ and stack contains Goal on top of $
B. All terminals are parsed
C. All non-terminals are reduced
D. Stack is full
Correct Answer: A
Chapter: 21
Q677:
The pair 〈A→β,k〉 includes which information?
A. A’s left-hand side and stack top
B. A production rule and its position
C. A token and its symbol
D. A derivation and grammar
Correct Answer: B
Chapter: 22
Q678:
What data structure is used in shift-reduce parsing to manage the input and parsing state?
A. Queue
B. Stack
C. Tree
D. List
Correct Answer: B
Chapter: 22
Q679:
In shift-reduce parsing, what does the "reduce" operation do?
A. Adds a terminal symbol
B. Pops symbols and pushes a non-terminal
C. Removes non-terminal symbols
D. Shifts next token onto the stack
Correct Answer: B
Chapter: 22
Q680:
The ► symbol in shift-reduce parsing represents the _______.
A. Bottom of the stack
B. Top of the stack
C. End of parsing
D. Error point
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now