Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Chapter: 22
Q701:
Stack-relative notation like Expr → Expr – • Term indicates parser is waiting to parse a _______.
A. Goal
B. Term
C. Minus
D. Expression
Correct Answer:
B
Chapter: 22
Q702:
The final reduction in the parse tree corresponds to which production?
A. Expr → Term
B. Goal → Expr
C. Factor → id
D. Term → Factor
Correct Answer:
B
Chapter: 22
Q703:
The handle ⟨Term → Term × Factor •⟩ indicates what?
A. Reduction is pending
B. Handle is complete
C. Parse error
D. Stack is empty
Correct Answer:
B
Chapter: 22
Q704:
A complete handle always ends with which symbol in stack-relative notation?
A. $
B. •
C. →
D. ⊢
Correct Answer:
B
Chapter: 22
Q705:
Which step in the example indicates accepting the input string?
A. Step 13
B. Step 15
C. Step 11
D. Step 9
Correct Answer:
B
Chapter: 22
Q706:
The parser uses a stack primarily to manage _______.
A. Error reporting
B. Grammar analysis
C. Input tokens
D. Parse frontier
Correct Answer:
D
Chapter: 23
Q707:
What is a handle in the context of bottom-up parsing?
A. A non-terminal on the LHS
B. A string to be shifted
C. A substring matching the RHS of a production
D. A DFA state
Correct Answer:
C
Chapter: 23
Q708:
Which of the following steps is typically taken by a bottom-up parser when it identifies a handle?
A. Shift
B. Reduce
C. Accept
D. Reject
Correct Answer:
B
Chapter: 23
Q709:
In a bottom-up parser, what does the placeholder "•" indicate?
A. An error in parsing
B. The end of a stack
C. The top of the parse stack
D. The lookahead symbol
Correct Answer:
C
Chapter: 23
Q710:
How many placeholder positions are there in a production with k symbols on the RHS?
A. k
B. k+1
C. k–1
D. k*2
Correct Answer:
B
Chapter: 23
Q711:
The number of complete handles in a grammar is equal to the number of __________.
A. productions
B. states
C. stack entries
D. reductions
Correct Answer:
A
Chapter: 23
Q712:
The total number of potential handles is equal to the ________ of the right-hand side lengths of all productions.
A. product
B. average
C. sum
D. maximum
Correct Answer:
C
Chapter: 23
Q713:
Which LR parser variant uses one-symbol lookahead?
A. LR(0)
B. SLR
C. LALR
D. LR(1)
Correct Answer:
D
Chapter: 23
Q714:
What is stored in the stack along with symbols in LR parsing to track DFA state?
A. Lookahead symbol
B. State number
C. Production ID
D. Action type
Correct Answer:
B
Chapter: 23
Q715:
Which table in LR parsing corresponds to terminals and DFA states?
A. Action table
B. Goto table
C. Parse table
D. Derivation table
Correct Answer:
A
Chapter: 23
Q716:
Which table is used to find transitions on non-terminals in LR parsers?
A. Action table
B. Goto table
C. Shift table
D. Stack table
Correct Answer:
B
Chapter: 23
Q717:
In the DFA model of LR parsing, rows represent DFA states. What do the columns represent?
A. Parsing errors
B. Non-terminals only
C. Terminals and non-terminals
D. Symbolic tokens
Correct Answer:
C
Chapter: 23
Q718:
What does LR(1) stand for in LR(1) parsers?
A. Left-to-right scan with 1 error
B. Lookahead Reduction with 1 shift
C. Left-to-right scan with 1-symbol lookahead
D. Lexical Reduction type 1
Correct Answer:
C
Chapter: 23
Q719:
LR(1) parsing technique uses ______ to resolve shift/reduce conflicts.
A. Top-down approach
B. Operator precedence
C. One-symbol lookahead
D. Recursion
Correct Answer:
C
Chapter: 23
Q720:
An LR(1) item includes a production rule and its ________.
A. Length
B. Follow set
C. Lookahead symbol
D. Non-terminal
Correct Answer:
C