Skip to main content

On Eliminating Unit Productions from LR(K) Parsers

  • Conference paper
  • 503 Accesses

Part of the book series: Lecture Notes in Computer Science ((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].

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

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   44.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   59.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Anderson, J., J. Eve, J.J. Horning, Efficient LR(1) parsers, Acta Informatica 2 (1973), 12–39.

    Article  MathSciNet  MATH  Google Scholar 

  2. Aho, A.V., J.D. Ullman, The Theory of Parsing, Translation and Compiling. Prentice-Hall, Englewood Cliffs, N.J., 1973.

    Google Scholar 

  3. Aho, A.V., J.D. Ullman, Optimization of LR(k) parsers, J. Computer and System Sciences 6 (1972), 573–602.

    Article  MathSciNet  MATH  Google Scholar 

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

    MATH  Google Scholar 

  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. DeRemer, F.L., Simple LR(k) grammars, Comm. ACM 14 (1971), 453–460.

    Article  MathSciNet  MATH  Google Scholar 

  7. Hayashi, T., On the construction of LR(k) analysers, Proc. ACM 1971 Annual Conf. (1971), 538–553.

    Google Scholar 

  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. Knuth, D.E., On the translation of languages from left to right, Inf. Contr. 8 (1965), 607–639.

    Article  MathSciNet  Google Scholar 

  10. Korenjak, A.J., A practical method for constructing LR(k) processors, Comm. ACM 12 (1969), 613–623.

    Article  MATH  Google Scholar 

  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. McKeeman, W.M., J.J. Horning, D.B. Wortman, A Compiler Generator, Englewood Cliffs, N.J., 1970.

    Google Scholar 

  13. Naur, P., et al., Revised report on the algorithmic language ALGOL 60, Comm. ACM 6 (1963), 1–17.

    Article  Google Scholar 

  14. Pager, D., A solution to an open problem by Knuth, Inf. Contr. 17 (1970), 462–473.

    Google Scholar 

  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. 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. Pager, D., Efficient programming techniques for LR(k) parsing, to appear in Comm. ACM.

    Google Scholar 

  18. Pager, D., The Lane Tracing Algorithm for constructing LR(k) parsers, to appear in Comm. ACM.

    Google Scholar 

  19. Pager, D., A time n2 left-to-right parser for context-free grammars, to appear in IEEE Trans. on Computers.

    Google Scholar 

  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. 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. 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. Pager, D., On the decremental approach to left-to-right parsers, to appear in SIAM J. Computing.

    Google Scholar 

  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. Pager, D., On eliminating unit reductions from LR(k) parsers, to appear in IEEE Trans. on Computers.

    Google Scholar 

  26. Sperry Rand Corp., UNIVAC 1108 ALGOL, Manual UP-7544, 1967.

    Google Scholar 

  27. Wirth, N., C.A.R. Hoare, A contribution to the development of ALGOL, Comm. ACM 9 (1966), 413–432.

    Article  MATH  Google Scholar 

  28. Wirth, N., H. Weber, EULER: a generalization of ALGOL, and its formal definition: Part II, Comm. ACM 9 (1966), 89–99.

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 1974 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Pager, D. (1974). On Eliminating Unit Productions from LR(K) Parsers. In: Loeckx, J. (eds) Automata, Languages and Programming. ICALP 1974. Lecture Notes in Computer Science, vol 14. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-662-21545-6_17

Download citation

  • DOI: https://doi.org/10.1007/978-3-662-21545-6_17

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-06841-9

  • Online ISBN: 978-3-662-21545-6

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics