Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q651: The grammar S → aABe, A → Abc | b, B → d generates which of the following sentences?
- A: abbcde
- B: abcde
- C: aabde
- D: abce
View Answer
A
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
View Answer
C
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
View Answer
D
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
View Answer
C
Q655: The top of the stack in shift-reduce parsing is marked by _______.
- A: $
- B: ►
- C: #
- D: *
View Answer
B
Q656: A bottom-up parser constructs the parse tree starting from _______.
- A: Root
- B: Leaves
- C: Top of stack
- D: Middle node
View Answer
B
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
View Answer
C
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
View Answer
D
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
View Answer
B
Q660: Which of the following is a valid representation of a handle?
- A: (A→β)
- B: 〈A→β,k〉
- C: (A←β)
- D: 〈β→A,k〉
View Answer
B