Summary
A new method for transforming grammars into equivalent LL(k) grammars is studied. The applicability of the transformation is characterized by defining a subclass of LR(k) grammars, called predictive LR(k) grammars, with the property that a grammar is predictive LR(k) if and only if the corresponding transformed grammar is LL(k). Furthermore, it is shown that deterministic bottom-up parsing of a predictive LR(k) grammar can be done by the LL(k) parser of the transformed grammar. This parsing method is possible since the transformed grammar always ‘left-to-right covers’ the original grammar. The class of predictive LR(k) grammars strictly includes the class of LC(k) grammars (the grammars that can be parsed deterministically in the left-corner manner). Thus our transformation is more powerful than the one previously available, which transforms LC(k) grammars into LL(k) form.
Similar content being viewed by others
References
Aho, A.V., Ullman, J.D.: The Theory of Parsing, Translation, and Compiling, Vol. I: Parsing. Englewood Cliffs, N.J.: Prentice-Hall 1972
Aho, A.V., Ullman, J.D.: The Theory of Parsing, Translation, and Compiling, Vol. II: Compiling. Englewood Cliffs, N.J.: Prentice-Hall 1973
Brosgol, B.M.: Deterministic translation grammars. Harvard University, Cambridge, Mass., Ph.D. Thesis, 1974
Burge, W.H.: Recursive Programming Techniques. Reading, Mass.: Addison-Wesley 1975
Cheatham, T.E., Jr.: The Theory and Construction of Compilers. Wakefield, Mass.: Computer Associates 1967
Demers, A.: Generalized left corner parsing. Conf. Record of the Fourth ACM Symposium on Principles of Programming Languages, pp. 170–182 (1977)
Foster, J.M.: A syntax improving program. Comput. J. 11, 31–34 (1968)
Greibach, S.A.: A new normal-form theorem for context-free phrase structure grammars. J. Assoc. Comput. Mach. 12:1, 42–52 (1965)
Griffiths, M.: LL(1) grammars and analysers. In: Compiler Construction: An Advanced Course, Lecture Notes in Computer Science, Vol. 21 (F.L. Bauer, J. Eickel, eds.), pp. 57–84. Berlin-Heidelberg-New York: Springer 1974
Griffiths, T.V., Petrick, S.R.: On the relative efficiencies of context-free grammar recognizers. Comm. ACM. 8, 289–300 (1965)
Griffiths, T.V., Petrick, S.R.: Top-down versus bottom-up analysis. In: Proc. of the IFIP congress 68, Vol. 1 (A.J.H. Morrell, ed.), pp. 80–85. Amsterdam: North-Holland 1969
Hammer, M.: A new grammatical transformation into deterministic top-down form. MIT, Mass., Project MAC Technical Report TR-119, 1974
Hammer, M.: A new grammatical transformation into LL(k) form. Proc. of Sixth Annual ACM Symposium on Theory of Computing, pp. 266–275 (1974)
Hopgood, F.R.A.: Compiling Techniques. New York, N.Y.: American Elsevier 1969
Irons, E.T.: A syntax directed compiler for ALGOL 60. Comm. ACM. 4, 51–55 (1961)
Knuth, D.E.: On the translation of languages from left to right. Information and Control 8, 607–639 (1965)
Knuth, D.E.: Top-down syntax analysis. Acta Informat. 1, 79–110 (1971)
Komor, T.: A note on left factored languages. Comput. J. 17, 242–244 (1974)
Kurki-Suonio, R.: On top-to-bottom recognition and left recursion. Comm. ACM. 9, 527–528 (1966)
Kurki-Suonio, R.: Notes on top-down languages. BIT 9, 225–238 (1969)
Lewis, P.M., II, Rosenkrantz, D.J., Stearns, R.E.: Compiler Design Theory. Reading, Mass.: Addison-Wesley 1976
Lewis, P.M., II, Stearns, R.E.: Syntax directed transduction. J. Assoc. Comput. Mach. 15, 464–488 (1968)
Nijholt, A.: On the covering of left-recursive grammars. Conf. Record of the Fourth ACM Symposium on Principles of Programming Languages, pp. 86–96 (1977)
Rosenkrantz, D.J.: Matrix equations and normal forms for context-free grammars. J. Assoc. Comput. Mach. 14, 501–507 (1967)
Rosenkrantz, D.J., Lewis, P.M., II: Deterministic left corner parsing. IEEE Conf. Record of 11th Annual Symposium on Switching and Automata Theory, pp. 139–152 (1970)
Rosenkrantz, D.J., Stearns, R.E.: Properties of deterministic top-down grammars. Information and Control 17, 226–256 (1970)
Soisalon-Soininen, E.: Characterization of LL(k) languages by restricted LR(k) grammars. Department of Computer Science, University of Helsinki, Helsinki, Report A-1977-3, 1977
Soisalon-Soininen, E., Ukkonen, E.: A characterization of LL(k) languages. In: Automata, Languages and Programming, Third Colloquium (S. Michaelson, R. Milner, eds.), pp. 20–30. Edinburgh: Edinburgh University Press 1976
Stearns, R.E.: Deterministic top-down parsing. Proc. Fifth Annual Princeton Conf. on Information Sciences and Systems, pp. 182–188 (1971)
Wood, D.: The normal form theorem — another proof. Comput. J. 12, 139–147 (1969)
Author information
Authors and Affiliations
Rights and permissions
About this article
Cite this article
Soisalon-Soininen, E., Ukkonen, E. A method for transforming grammars into LL(k) form. Acta Informatica 12, 339–369 (1979). https://doi.org/10.1007/BF00268320
Received:
Issue Date:
DOI: https://doi.org/10.1007/BF00268320