Exercises 05
Exercise 1
Short questions:
- Describe the language that is accepted by an LL(0) grammar.
- Describe why a shift/shift conflict is impossible during the LR table construction.
- Is is possible that a SLR parser prefers reduction in a shift/reduce conflict?
Exercise 2
Construct an LR(0) parsing table for the following grammar.
S -> SS | (S) | ()
- Locate the shift/reduce conflict in the table.
- Using some test inputs, resolve the conflict in favor of a shift or a reduction.
Exercise 3
Construct an SLR parse table for the following grammar.
S -> E + E E -> E * a S -> a E -> a
- Is SLR powerful enough to resolve the conflicts?
- Draw the LR(1) automaton for parsing.
- Determine the set of states that can be merged for an LALR parser.