Java Reference
In-Depth Information
13. Discuss why is it not possible during LR(0) construction to obtain a
shift
/
reduce conflict on a nonterminal.
14. Discuss why there cannot be an unambiguous CFGs for the language
a i b j c k | i = j or j = k ; i , j , k
{
1
}
15. Complete the LR(0) construction for the grammar in Figure 6.19.
16. Show that LL(1) construction fails for an unambiguous grammar that is
not LR(1).
17. Show that the grammar in Figure 6.20 is LR(0).
18. Complete the LR(0) construction for the grammar shown in Figure 6.25.
Your state numbers should agree with those shown in the partial LR(0)
construction.
19. Which of the grammars in Exercise 10 are LR(0)? Justify your answers.
20. Complete the SLR(1) construction for the grammar shown in Figure 6.26.
Show the resulting parse table.
21. Extend the grammar given in Figure 6.21 to accommodate standard ex-
pressions involving addition, subtraction, multiplication, and division.
Model the syntax and semantics for these operators according to Java
or C.
22. Extend the grammar as directed in Exercise 21, but introduce an expo-
nentiation operator that is right-associating . Let the operator (denoted by
”) have the highest priority, so that the value of 3
+
4
×
5
2 is 103.
23. Repeat Exercise 22, but add the ability to enclose expressions with paren-
theses to control how expressions are grouped together. Thus, the value
of ((3
+
4)
×
5)
2 is 1225.
24. Which of the grammars in Exercise 10 are SLR(1)? Justify your answers.
25. Generalize the algorithm given in Section 6.5.1 from SLR(1) to SLR( k ).
 
Search WWH ::




Custom Search