Testing Grammars for Parsability
In the preceding chapters we have studied in detail the major methods of deterministic context-free parsing: strong LL(k) parsing (Chapter 5), simple precedence parsing (Chapter 5), canonical LR(k) parsing, LALR(k) parsing, and SLR(k) parsing (Chapters 6 and 7), and canonical LL(k) parsing (Chapter 8). Each of these methods induces a class of grammars that are “parsable” using that method, that is, a class of grammars for which a deterministic parser employing that method can be constructed. For example, the LL(k) grammars constitute the class of grammars parsable by the LL(k) parsing method. By definition, a context-free grammar is an LL(k) grammar if and only if its canonical LL(k) parser is deterministic.
KeywordsHunt Prefix Suffix
Unable to display preview. Download preview PDF.
- The fundamental result that for any fixed natural number k there exists a polynomial time-bounded deterministic algorithm for testing a context-free grammar for the LR(k) property is already present in the paper by Knuth (1965). The algorithm given by Knuth is essentially that implied by the nondeterministic finite automaton M k (G’) (Theorem 10.11). In place of a finite automaton Knuth used a right-linear grammar. The idea of using in place of M k (G’) a collection of more succinct automata Mu(G’) was suggested by Hunt, Szymanski and Ullman (1975). From them comes Theorem 10.21. Hunt, Szymanski and Ullman were also the first to investigate the nondeterministic complexity of non-LR(k) testing and the effect of the role of k in the complexity. From their paper come Theorem 10.24 and the results for SLR(k) testing (Theorems 10.28 and 10.30). The improved time bound for SLR(1) testing (Exercise 10.19) is from Hunt, Szymanski and Ullman (1974, 1977), and the improved time bound fer SLR(2) testing is from Sippu and SoisalonSoininen (1985).Google Scholar
- The linear-time reduction of LL(k) testing to LR(k) testing comes from Brosgol (1974). The more general formulation of the result (Theorem 10.34) was stated by Hunt and Szymanski (1978). The results for SLL(k) testing (Theorems 10.45 and 10.47) and the results for LL(k) testing obtained via the use of the automata Mu_Set ( G’) (Theorems 10.57 and 10.59) come from Sippu and Soisalon-Soininen (1983a). Reductions between different grammar classes are considered by Hunt and Szymanski (1978), who also study the complexity of relative decision problems, for example, the complexity of determining for an LR(k) grammar whether or not the grammar is LL(k) for some k’. Google Scholar
- The notion of a Turing machine comes from Turing (1936). The version of a Turing machine defined in Section 10.3 is what is usually called a “nondeterministic Turing machine with one semi-infinite tape”. The formulation as a rewriting system has been adopted from Salomaa (1973). For the basic results on Turing machines and computational complexity, see Salomaa (1973), Aho, Hoperoft and Ullman (1974), and Hoperoft and Ullman (1979).Google Scholar
- The idea of embedding Turing machine computations in context-free languages (Theorems 10.64 and 10.65) comes from Hartmanis (1967) (also see Hunt, 1982). The hardness of uniform non-LR(k), non-LALR(k), non-SLR(k), non-LL(k), and non-SLL(k) testing (Theorems 10.75 and 10.77) was established by Hunt, Szymanski and Ullman (1975). The unsolvability of the existence of k such that a given context-free grammar is LR(k) or LL(k) (Theorem 10.78) comes from Knuth (1965) and from Rosenkrantz and Stearns (1970). Rosenkrantz and Stearns proved the result for LL(k) by presenting a generic transformation. Knuth proved the result for LR(k) via a reduction from a variant of Post’s correspondence problem (Exercise 10.51). The original formulation of Post’s correspondence problem comes from Post (1946). The hardness of bounded variants of the problem (Exercise 10.53) is considered by Constable, Hunt and Sahni (1974). The variant given in Exercise 10.55 was suggested by Otto Nurmi and is especially suitable for proving the hardness of the uniform testing problems.Google Scholar
- The results on the hardness of regular expression nonuniversality (Theorem 10.81 and Exercise 10.62) come from Meyer and Stockmeyer (1972) and Stockmeyer and Meyer (1973). Other decision problems on regular languages are considered by Hunt, Rosenkrantz and Szymanski (1976), Hunt and Rosenkrantz (1978), and Hunt (1979). The reduction of regular expression nonuniversality to non-LALR(k) testing (Theorem 10.85) and the hardness result for the fixed k 1 case (Theorem 10.86) are from Ukkonen and Soisalon-Soininen (1981) and from Sippu, Soisalon-Soininen and Ukkonen (1983). The corresponding reduction for LALL(k) testing (Theorem 10.87) can be found in Sippu and Soisalon-Soininen (1983a). The upper bounds for uniform non-LALR(k) and non-LALL(k) testing (Theorem 10.88) can be found in Sippu, Soisalon-Soininen and Ukkonen (1983) and in Sippu and Soisalon-Soininen (1983a).Google Scholar
- The solvability and complexity of diffferent kinds of decision problems on context-free grammars are studied by Hunt, Rosenkrantz and Szymanski (1976), Hunt and Szymanski (1976), Hunt and Rosenkrantz (1977, 1978, 1980), Hunt (1982), Heilbrunner (1983), and Rosenkrantz and Hunt (1985, 1987).Google Scholar