Skip to main content
Log in

On the space optimizing effect of eliminating single productions from LR parsers

  • Published:
Acta Informatica Aims and scope Submit manuscript

Summary

Single productions in the syntax of a programming language usually have no semantic significance, and thus parsers can be modified so that they do not perform reductions by single productions. In this paper we show that the basic method developed by Pager for eliminating all undesired single productions from LR parsers can cause a quadratic increase in the number of states of the parser. We then define an improvement of Pager's basic method such that generally smaller parsers are produced; in fact, even a quadratic decrease in the number of states is possible. This improvement is further evaluated by giving a sequence of practically motivated grammars for which substantial savings in space are obtained. We also characterize this improvement by a grammatical condition under which it is guaranteed that no increase in the number of states can occur. This condition is compared with a similar condition derivable in the case of Pager's original method.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Aho, A.V., Ullman, J.D.: The theory of parsing, translation and compiling, Vol. I: Parsing. Englewood Cliffs, N.J.: Prentice Hall 1972

    Google Scholar 

  2. Aho, A.V., Ullman, J.D.: Optimization of LR(k) parsers. J. Comput. System Sci. 6, 573–602 (1972)

    Google Scholar 

  3. Aho, A.V., Ullman, J.D.: The theory of parsing, translation and compiling, Vol. II: Compiling. Englewood Cliffs, N.J.: Prentice Hall 1973

    Google Scholar 

  4. Aho, A.V., Ullman, J.D.: A technique for speeding up LR(k) parsers. SIAM J. Computing 2, 106–127 (1973)

    Google Scholar 

  5. Anderson, T.: Syntactical analysis of LR(k) languages. University of Newcastle upon Tyne, Computing Lab., England, Ph.D. Thesis, 1972

    Google Scholar 

  6. Anderson, T., Eve, J., Horning, J.J.: Efficient LR(1) parsers. Acta Informat. 2, 12–39 (1973)

    Google Scholar 

  7. Backhouse, R.C.: An alternative approach to the improvement of LR(k) parsers. Acta Informat. 6, 277–296 (1976)

    Google Scholar 

  8. Demers, A.J.: Elimination of single productions and merging nonterminal symbols of LR(1) grammars. Comput. Lang. 1, 105–119 (1975)

    Google Scholar 

  9. DeRemer, F.L.: Practical translators for LR(k) languages. Project MAC, Mass. Inst. of Tech., Cambridge, Tech. Report MAC TR-65, October 1969

    Google Scholar 

  10. DeRemer, F.L.: Simple LR(k) grammars. Comm. ACM 14, 453–460 (1971)

    Google Scholar 

  11. Joliat, M.L.: A simple technique for partial elimination of unit productions from LR(k) parsers. IEEE Trans. Comput. C-27 (Corresp.), 763–764 (1976)

  12. Knuth, D.E.: On the translation of languages from left to right. Information and Control 8, 607–639 (1965)

    Google Scholar 

  13. Koskimies, K., Soisalon-Soininen, E.: On a method for optimizing LR parsers. Internat. J. Comput. Math. 7, 287–295 (1979)

    Google Scholar 

  14. LaLonde, W.R.: An efficient LALR parser generator. Computer Systems Research Group, Univ. of Toronto, Tech. Report CSRG-2, 1971

  15. LaLonde, W.R.: On directly constructing LA(k)LR(m) parsers without chain productions. Department of Systems Engineering and Computing Science, Carleton Univ., Ottawa, Tech. Report No. SE and CS 76-9, 1976

    Google Scholar 

  16. LaLonde, W.R.: On directly constructing LR(k) parsers without chain reductions. Conf. Record of the Third-ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, 127–133 (1976)

  17. Pager, D.: A solution to an open problem by Knuth. Information and Control 17, 462–473 (1970)

    Google Scholar 

  18. Pager, D.: On eliminating unit productions from LR(k) parsers. In: Automata, languages and programming, 2nd Colloquium (J. Loeckx, ed.), Lecture Notes in Computer Science, Vol. 14. Berlin Heidelberg New York: Springer 1974

    Google Scholar 

  19. Pager, D.: Eliminating unit productions from LR parsers, Acta Informat. 9, 31–59 (1977)

    Google Scholar 

  20. Rushby, J.M.: LR(k) sparse parsers and their optimization. Department of Computer Science, University of Newcastle upon Tyne, England, Ph. D. Thesis, September 1977

    Google Scholar 

  21. Soisalon-Soininen, E.: Elimination of single productions from LR parsers in conjunction with the use of default reductions. Conf. Record of the Fourth ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, 183–193 (1977)

Download references

Author information

Authors and Affiliations

Authors

Additional information

Part of this work was carried out when the author was visiting the University of California, Department of Mathematics, at Santa Barbara as an ASLA Fulbright Scholar

Rights and permissions

Reprints and permissions

About this article

Cite this article

Soisalon-Soininen, E. On the space optimizing effect of eliminating single productions from LR parsers. Acta Informatica 14, 157–174 (1980). https://doi.org/10.1007/BF00288542

Download citation

  • Received:

  • Revised:

  • Issue Date:

  • DOI: https://doi.org/10.1007/BF00288542

Keywords

Navigation