232_Sheet_08_01
232_Sheet_08_01
Alfred Aho, Monica Lam, Ravi Sethi, and Jeffrey Ullman. Addison-Wesley
1. Consider the grammar
3. What are the items in the initial state of the SLR(1) parsing automaton for the grammar in
last question(Question 1)?
4. Which of the following are true of the initial state of the SLR(1) parsing automaton from the
last question (Question 2)?
[Choose all that apply]
a) This state has a shift-reduce conflict on input x.
b) The state has a reduce-reduce conflict on input x.
c) The state has a reduce-reduce conflict on transition S.
d) This state has a shift-reduce conflict on transition S.
e) This state has a shift-reduce conflict on end-of-input.
f) This state has a shift-reduce conflict on input '('.
g) The state has a reduce-reduce conflict on end-of-input.
h) The state has a reduce-reduce conflict on input '('.
The number of symbols in the first sets for the *non-terminals* are: ?
6. Given the following grammar,
7. For the grammar in last question (Question 5), when applying shift-reduce parsing to the
same string:
if a then if b then win else loss
What kind of conflicts will we have?
Using shift-reduce parsing, how many shift and how many reduce moves does it take to
accept the input string:
((int + int)*int)
a) LL(1)
b) SLR(1) but not LL(1)
c) not SLR(1)
12. Which of the following statements are true about this grammar: