Java Reference
In-Depth Information
a. Is this grammar LL(1)? If not, derive an equivalent grammar that is LL(1).
b. Construct the LL(1) parsing table for the LL(1) grammar.
c. Show the steps in parsing notiandiori .
Exercise 3.15. Consider the following grammar:
S ::= L = R
S ::= R
L ::= * R
L ::= i
R ::= L
a. Construct the canonical LR(1) collection.
b. Construct the Action and Goto tables.
c. Show the steps in the parse for *i=i .
Exercise 3.16. Consider the following grammar:
S ::= ( L ) j a
L ::= L , S j S
a. Compute the canonical collection of LR(1) items for this grammar.
b. Construct the LR(1) parsing table for this grammar.
c. Show the steps in parsing the input string ((a,a),a) .
d. Is this an LALR(1) grammar?
Exercise 3.17. Consider the following grammar.
S ::= A a j b A c j dc j bda
A ::= d
a. What is the language described by this grammar?
b. Compute first and follow for all non-terminals.
c. Construct the LL(1) parsing table for this grammar. Is it LL(1)? Why?
d. Construct the LR(1) canonical collection, and the Action and Goto tables for this gram-
mar. Is it LR(1)? Why or why not?
Exercise 3.18. Is the following grammar LR(1)? LALR(1)?
S ::= C C
C ::= a C j b
Exercise 3.19. Consider the following context-free grammar:
S ::= A a j b A c j dc j bda
A ::= d
a. Compute the canonical LR(1) collection for this grammar.
 
Search WWH ::




Custom Search