Skip to main content

Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Chapter: 23
Q721:
Which of the following is an example of a potential handle for Term → Term × Factor?
A. 〈Term → • Term × Factor〉
B. 〈Term → Term • × Factor〉
C. 〈Term → Term × • Factor〉
D. All of the above
Correct Answer: D
Chapter: 23
Q722:
The parsing table with terminals and DFA states is known as the _________.
A. Action table
B. Goto table
C. LALR table
D. Transition table
Correct Answer: A
Chapter: 23
Q723:
To resolve shift/reduce conflict, parser considers ________.
A. Grammar tree
B. Operator precedence
C. Lookahead symbol
D. First and follow sets
Correct Answer: C
Chapter: 23
Q724:
The representation of a handle with a lookahead in LR(1) parsing is called ________.
A. DFA state
B. LR(1) item
C. Handle ID
D. Grammar node
Correct Answer: B
Chapter: 23
Q725:
What action is taken when the parser sees Expr – Term × id?
A. Reduce to Expr
B. Reduce to Term
C. Shift
D. Accept
Correct Answer: C
Chapter: 23
Q726:
How does a parser know whether to reduce or shift at step 9?
A. Length of stack
B. Input symbol
C. Right context of handle
D. Grammar goal
Correct Answer: C
Chapter: 23
Q727:
At step 13 of bottom-up parsing, which reduction occurs?
A. Expr → Term
B. Expr → Expr – Term
C. Term → Factor
D. Factor → id
Correct Answer: B
Chapter: 23
Q728:
What does the parser do when the input matches no handle?
A. Shift
B. Backtrack
C. Error
D. Accept
Correct Answer: C
Chapter: 23
Q729:
In LR parsing, rows are DFA states and columns with non-terminals form the ________.
A. Action table
B. Goto table
C. Derivation table
D. State index
Correct Answer: B
Chapter: 23
Q730:
Which of the following is the correct notation for a handle at the top of the stack?
A. 〈Expr → • Term〉
B. 〈Expr → Term •〉
C. 〈Expr • Term〉
D. 〈•Expr → Term〉
Correct Answer: B
Chapter: 23
Q731:
Expr → Expr – Term • is an example of ________.
A. Grammar rule
B. Reduction step
C. Completed handle
D. Parsing error
Correct Answer: C
Chapter: 23
Q732:
The parser recognizes handles using ________.
A. Grammar productions
B. Parsing tables
C. Stack size
D. DFA transitions
Correct Answer: D
Chapter: 23
Q733:
The handle-finding mechanism is crucial for ________.
A. Top-down parsing
B. Bottom-up parsing
C. Recursive descent parsing
D. LL parsers
Correct Answer: B
Chapter: 23
Q734:
The LR(1) parser constructs tables using a model of ________.
A. Grammar tree
B. Parse forest
C. Handle-recognizing DFA
D. Symbol precedence
Correct Answer: C
Chapter: 23
Q735:
Parsing tables are generated using the ________ of the DFA.
A. Transitions
B. Stack
C. Lookahead symbols
D. Derivations
Correct Answer: A
Chapter: 23
Q736:
To remember DFA state transitions, parsers store ______ in the stack.
A. Only terminals
B. Non-terminals and terminals
C. Symbols and state numbers
D. State machines
Correct Answer: C
Chapter: 24
Q737:
An LR(1) item is represented as a pair consisting of a production and a ________.
A. Non-terminal
B. Lookahead symbol
C. Grammar rule
D. Stack symbol
Correct Answer: B
Chapter: 24
Q738:
The set of LR(1) items representing each parser state is called the ________.
A. Parsing stack
B. Canonical Collection
C. Handle set
D. Closure set
Correct Answer: B
Chapter: 24
Q739:
The initial state in the canonical collection is labeled as ________.
A. I0
B. I1
C. S0
D. S1
Correct Answer: A
Chapter: 24
Q740:
In the augmented grammar, a new start symbol S is added with the production ________.
A. S → S
B. E → E + (E)
C. S → E
D. E → int
Correct Answer: C

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now