Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 20
Q641:
abbcde reduces to S in which grammar?
A. S → aABe; A → Abc | b; B → d
B. S → abcde
C. S → abcd
D. S → aAbce
Correct Answer: A
Chapter: 20
Q642:
If γ contains only terminals, γ is a ______.
A. Sentence
B. Non-terminal
C. Production
D. Grammar
Correct Answer: A
Chapter: 20
Q643:
In shift-reduce parsing, which of the following is NOT an action?
A. Shift
B. Reduce
C. Expand
D. Accept
Correct Answer: C
Chapter: 20
Q644:
Shift action is used to move a ______ to the left string.
A. Non-terminal
B. Terminal
C. Error
D. Derivation
Correct Answer: B
Chapter: 20
Q645:
In bottom-up parsing, the input string is initially in what state?
A. Fully reduced
B. Partially parsed
C. Fully unexamined
D. Fully derived
Correct Answer: C
Chapter: 20
Q646:
The dividing point between examined and unexamined input in parsing is marked by ______.
A. $
B. ►
C. #
D. *
Correct Answer: B
Chapter: 20
Q647:
In shift-reduce parsing, what does E → int represent?
A. A terminal match
B. Reduction rule
C. A grammar conflict
D. None of the above
Correct Answer: B
Chapter: 20
Q648:
Which string represents the final reduced form in the example: int + (int) + (int)?
A. E
B. E + E
C. E + (E)
D. E + (E) + (E)
Correct Answer: A
Chapter: 20
Q649:
How many kinds of actions are used in bottom-up parsing?
A. 1
B. 2
C. 3
D. 4
Correct Answer: B
Chapter: 20
Q650:
Which is NOT a characteristic of bottom-up parsing?
A. It reads tokens left to right
B. It builds leftmost derivation
C. It uses shift-reduce
D. It constructs rightmost derivation in reverse
Correct Answer: B
Chapter: 20
Q651:
The grammar S → aABe, A → Abc | b, B → d generates which of the following sentences?
A. abbcde
B. abcde
C. aabde
D. abce
Correct Answer: A
Chapter: 21
Q652:
What does the shift action do in a shift-reduce parser?
A. Pops a symbol from the stack
B. Pushes a non-terminal onto the stack
C. Pushes a terminal onto the stack
D. Removes the top of the stack
Correct Answer: C
Chapter: 21
Q653:
What happens during the reduce action in shift-reduce parsing?
A. A non-terminal is shifted
B. A symbol is deleted
C. A terminal is added
D. Zero or more symbols are popped and a non-terminal is pushed
Correct Answer: D
Chapter: 21
Q654:
In shift-reduce parsing, what does the stack represent?
A. The input buffer
B. The rightmost derivation
C. The upper frontier of the parse tree
D. The lower frontier of the parse tree
Correct Answer: C
Chapter: 21
Q655:
The top of the stack in shift-reduce parsing is marked by _______.
A. $
B. ►
C. #
D. *
Correct Answer: B
Chapter: 21
Q656:
A bottom-up parser constructs the parse tree starting from _______.
A. Root
B. Leaves
C. Top of stack
D. Middle node
Correct Answer: B
Chapter: 21
Q657:
Which part of the parse tree is referred to as the "upper frontier"?
A. The leaves
B. The root
C. The partially constructed top edge
D. The bottommost node
Correct Answer: C
Chapter: 21
Q658:
What is the critical step in building a bottom-up parser?
A. Finding the start symbol
B. Matching terminals
C. Building the stack
D. Finding a match along the current frontier
Correct Answer: D
Chapter: 21
Q659:
A handle in bottom-up parsing refers to _______.
A. The entire input
B. The right-hand side of a production and its position
C. The left-hand side of a production
D. The next token in input
Correct Answer: B
Chapter: 21
Q660:
Which of the following is a valid representation of a handle?
A. (A→β)
B. 〈A→β,k〉
C. (A←β)
D. 〈β→A,k〉
Correct Answer: B

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now