
CMSC 430, Practice Problems 2
1. Bottom up parsing
a. Describe the difference between bottom-up and top-down parsing with respect
to a grammar production A → β
b. Define handle
c. Explain why bottom-up parsers result in right-most derivations in reverse.
d. Given the following ACTION/GOTO table, perform a parse of “a”, assuming
0 is the start state. Show the contents of the stack, remaining input, and action
performed at each step of the shift-reduce parse.
2. LR parsing
a. What is the canonical set of LR(k) items for a grammar?
b. What are ACTION/GOTO tables of an LR(k) parser for a grammar?
c. Given an LR(k) item [A → α•γ,
δ] from a production A → β, describe the
role of A, α, γ, δ
d. Given an LR(k) item [A → α•γ,
δ], what lookahead allows a shift to be
performed (ignoring any other LR(k) items added to the state by closure)?
e. Given an LR(k) item [A → α•γ,
δ], what LR(k) items must be added to the
closure?
f. If the parser is in a state containing an LR(k) item [A → α•γ,
δ], what must be
at the top of the stack, and why?
g. Describe what constitutes a shift/reduce conflict
h. Give an example of two LR(1) items causing a reduce/reduce conflict.
i. Explain why there are no shift/shift conflicts
3. LALR parsing.
Consider the following sets of LR(1) items in the states of a LR(1) parser.