Advertisement

On eliminating unit productions from LR(k) parsers

  • David Pager
Tuesday Afternoon
Part of the Lecture Notes in Computer Science book series (LNCS, volume 14)

Abstract

LR(k) parsers have attracted a lot of attention recently [1–11, 14–25] as providing the most efficient method of parsing a wide subset of the context-free languages and most computer languages including ALGOL and FORTRAN. In this paper we show how one can improve upon an algorithm by Aho and Ullman [4] for eliminating unit productions from an LR(k) parser so that the elimination concerned can be made in all cases, instead of only in the special case required by [4] where no two unit productions have the same left-hand side. In most practical grammars this special case does not in fact arise. Since the elimination of unit productions both reduces the size of the parser and increases its speed, it is of value to have a general method for achieving this objective. The algorithm provided eliminates from the parser all nonterminals which occur as left-hand sides of unit productions. This substantially contributes to the reduction in size obtained, and also provides a solution to an open problem by Aho and Ullman [4]. The sizes of the parsers obtained using the parser's algorithm are compared with those of Anderson, Eve, and Horning [1].

Keywords

Unit Production Input String Input Symbol Unit Reduction Large State Number 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Anderson, J., J. Eve, J.J. Horning, Efficient LR(1) parsers, Acta Informatica 2 (1973), 12–39.CrossRefGoogle Scholar
  2. 2.
    Aho, A.V., J.D. Ullman, The Theory of Parsing, Translation and Compiling. Prentice-Hall, Englewood Cliffs, N.J., 1973.Google Scholar
  3. 3.
    Aho, A.V., J.D. Ullman, Optimization of LR(k) parsers, J. Computer and System Sciences 6 (1972), 573–602.Google Scholar
  4. 4.
    Aho, A.V., J.D. Ullman, A technique for speeding up LR(k) parsers, SIAM J. Comput. 2 (1973), 106–127.CrossRefGoogle Scholar
  5. 5.
    DeRemer, F.L., Practical translators for LR(k) languages, Tech. Report MAC TR-65, Project MAC, Mass. Inst. of Tech., Cambridge, October 1969.Google Scholar
  6. 6.
    DeRemer, F.L., Simple LR(k) grammars, Comm. ACM 14 (1971), 453–460.CrossRefGoogle Scholar
  7. 7.
    Hayashi, T., On the construction of LR(k) analysers, Proc. ACM 1971 Annual Conf. (1971), 538–553.Google Scholar
  8. 8.
    Joliat, M.L., On the reduced matrix representation of LR(k) parser tables, Tech. Report CSRG-28, Computer Systems Research Group, University of Toronto, Toronto, October 1973.Google Scholar
  9. 9.
    Knuth, D.E., On the translation of languages from left to right, Inf. Contr. 8 (1965), 607–639.CrossRefGoogle Scholar
  10. 10.
    Korenjak, A.J., A practical method for constructing LR(k) processors, Comm. ACM 12 (1969), 613–623.CrossRefGoogle Scholar
  11. 11.
    LaLonde, W.R., An efficient LALR parser generator, Tech. Report CSRG-2, Computer Systems Research Group, University of Toronto, Toronto, 1971.Google Scholar
  12. 12.
    McKeeman, W.M., J.J. Horning, D.B. Wortman, A Compiler Generator, Englewood Cliffs, N.J., 1970.Google Scholar
  13. 13.
    Naur, P., et al., Revised report on the algorithmic language ALGOL 60, Comm. ACM 6 (1963), 1–17.CrossRefGoogle Scholar
  14. 14.
    Pager, D., A solution to an open problem by Knuth, Inf. Contr. 17 (1970), 462–473.CrossRefGoogle Scholar
  15. 15.
    Pager, D., Conditions for the existence of minimal closed covers composed of maximal compatibles, IEEE Trans. Comput. C-20 (1971), 450–452.Google Scholar
  16. 16.
    Pager, D., Some ideas for research on left-to-right parsing, Tech. Report No. PE 84, Information Sciences Program, University of Hawaii, Honolulu, October 1970.Google Scholar
  17. 17.
    Pager, D., Efficient programming techniques for LR(k) parsing, to appear in Comm. ACM.Google Scholar
  18. 18.
    Pager, D., The Lane Tracing Algorithm for constructing LR(k) parsers, to appear in Comm. ACM.Google Scholar
  19. 19.
    Pager, D., A time n2 left-to-right parser for context-free grammars, to appear in IEEE Trans. on Computers.Google Scholar
  20. 20.
    Pager, D., On combining compatible states in LR(k) parsing, Tech. Report PE 257, Information Sciences Program, University of Hawaii, Honolulu, July 1972.Google Scholar
  21. 21.
    Pager, D., A compaction algorithm for combining the symbol-action lists of an LR(k) parser, Tech. Report PE 259, Information Sciences Program, University of Hawaii, Honolulu, July 1972.Google Scholar
  22. 22.
    Pager, D., Compactions made in the parser for a subset of a BASIC, Tech. Report PE 283, Information Sciences Program, University of Hawaii, Honolulu, September 1972.Google Scholar
  23. 23.
    Pager, D., On the decremental approach to left-to-right parsers, to appear in SIAM J. Computing.Google Scholar
  24. 24.
    Pager, D., On implementing the revised algorithm for eliminating unit reductions, Tech. Report PE 312, Information Sciences Program, University of Hawaii, Honolulu, January 1973.Google Scholar
  25. 25.
    Pager, D., On eliminating unit reductions from LR(k) parsers, to appear in IEEE Trans. on Computers.Google Scholar
  26. 26.
    Sperry Rand Corp., UNIVAC 1108 ALGOL, Manual UP-7544, 1967.Google Scholar
  27. 27.
    Wirth, N., C.A.R. Hoare, A contribution to the development of ALGOL, Comm. ACM 9 (1966), 413–432.CrossRefGoogle Scholar
  28. 28.
    Wirth, N., H. Weber, EULER: a generalization of ALGOL, and its formal definition: Part II, Comm. ACM 9 (1966), 89–99.CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1974

Authors and Affiliations

  • David Pager
    • 1
  1. 1.Department of Computer ScienceUniversity of HawaiiUSA

Personalised recommendations