Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 22
Q681:
Which direction does a bottom-up parser build the parse tree?
A. Top to bottom
B. Root to leaf
C. Leaf to root
D. Random
Correct Answer: C
Chapter: 22
Q682:
What is the upper frontier in a bottom-up parser?
A. The left-most leaf
B. The root of the tree
C. The rightmost input token
D. The edge of the partially constructed parse tree
Correct Answer: D
Chapter: 22
Q683:
Which of the following describes a handle in bottom-up parsing?
A. A terminal to be deleted
B. A left-hand side symbol
C. A pair representing a match of a production
D. A complete input stream
Correct Answer: C
Chapter: 22
Q684:
A handle is represented by which of the following?
A. ⟨A→β,k⟩
B. β→A
C. 〈k,β→A〉
D. ⟨β→A⟩
Correct Answer: A
Chapter: 22
Q685:
In a handle ⟨A→β,k⟩, what does 'k' represent?
A. Number of productions
B. Position on stack
C. Right-end of β on the frontier
D. Production index
Correct Answer: C
Chapter: 22
Q686:
Which one is a valid handle from the sample?
A. ⟨Expr → Term •⟩
B. ⟨Expr ← Term •⟩
C. ⟨Expr → • Term⟩
D. ⟨Expr = Term ⟩
Correct Answer: A
Chapter: 22
Q687:
How many handles are identified in the sample expression parse process?
A. 5
B. 7
C. 9
D. 3
Correct Answer: C
Chapter: 22
Q688:
What happens when a handle is reduced in shift-reduce parsing?
A. New token is created
B. Partial tree is discarded
C. New node is added to parse tree
D. Input token is ignored
Correct Answer: C
Chapter: 22
Q689:
What is the final handle that confirms successful parsing?
A. ⟨Goal → Expr,1⟩
B. ⟨Expr → Term,1⟩
C. ⟨Factor → id,1⟩
D. ⟨Goal → Term,1⟩
Correct Answer: A
Chapter: 22
Q690:
Which expression is used to represent the top of the stack in handle notation?
A. ▲
B. ▼
C. •
D. ∗
Correct Answer: C
Chapter: 22
Q691:
What is the first step in shift-reduce parsing algorithm?
A. shift symbol
B. lookup production
C. pop all elements
D. push $ on stack
Correct Answer: D
Chapter: 22
Q692:
The handle ⟨Expr → Expr – Term •⟩ shows what parsing state?
A. Production is incomplete
B. Right-hand side is matched
C. Goal reached
D. Error occurred
Correct Answer: B
Chapter: 22
Q693:
In step 2 of the example, which production is applied?
A. Factor → num
B. Term → Factor
C. Expr → Term
D. Factor → id
Correct Answer: D
Chapter: 22
Q694:
After reducing ⟨Term → Factor⟩, what is pushed to the stack?
A. id
B. Term
C. Expr
D. Goal
Correct Answer: B
Chapter: 22
Q695:
In the parsing sequence, what comes after reducing ⟨Expr → Expr – Term⟩?
A. Shift next token
B. Accept
C. Reduce to Goal
D. Error occurs
Correct Answer: C
Chapter: 22
Q696:
In expression grammar parsing, when does the parser accept the input?
A. When no symbols are left
B. When input ends with id
C. When Goal is on top of stack over $
D. When expression reduces to Term
Correct Answer: C
Chapter: 22
Q697:
The production Expr → Expr – Term has how many placeholder positions?
A. 2
B. 3
C. 4
D. 5
Correct Answer: C
Chapter: 22
Q698:
Placeholder position “Expr → • Expr –Term” means parser is about to parse ______.
A. Term
B. Expr
C. Minus
D. Goal
Correct Answer: B
Chapter: 22
Q699:
The stack helps eliminate the need to track the _______ of a handle.
A. Grammar symbol
B. Value
C. Position
D. Production index
Correct Answer: C
Chapter: 22
Q700:
The shift-reduce parser can handle expressions such as:
A. x + y – z
B. x – 2 × y
C. x * y / z
D. a + b + c
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now