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
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
Anderson, J., J. Eve, J.J. Horning, Efficient LR(1) parsers, Acta Informatica 2 (1973), 12–39.
Aho, A.V., J.D. Ullman, The Theory of Parsing, Translation and Compiling. Prentice-Hall, Englewood Cliffs, N.J., 1973.
Aho, A.V., J.D. Ullman, Optimization of LR(k) parsers, J. Computer and System Sciences 6 (1972), 573–602.
Aho, A.V., J.D. Ullman, A technique for speeding up LR(k) parsers, SIAM J. Comput. 2 (1973), 106–127.
DeRemer, F.L., Practical translators for LR(k) languages, Tech. Report MAC TR-65, Project MAC, Mass. Inst. of Tech., Cambridge, October 1969.
DeRemer, F.L., Simple LR(k) grammars, Comm. ACM 14 (1971), 453–460.
Hayashi, T., On the construction of LR(k) analysers, Proc. ACM 1971 Annual Conf. (1971), 538–553.
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.
Knuth, D.E., On the translation of languages from left to right, Inf. Contr. 8 (1965), 607–639.
Korenjak, A.J., A practical method for constructing LR(k) processors, Comm. ACM 12 (1969), 613–623.
LaLonde, W.R., An efficient LALR parser generator, Tech. Report CSRG-2, Computer Systems Research Group, University of Toronto, Toronto, 1971.
McKeeman, W.M., J.J. Horning, D.B. Wortman, A Compiler Generator, Englewood Cliffs, N.J., 1970.
Naur, P., et al., Revised report on the algorithmic language ALGOL 60, Comm. ACM 6 (1963), 1–17.
Pager, D., A solution to an open problem by Knuth, Inf. Contr. 17 (1970), 462–473.
Pager, D., Conditions for the existence of minimal closed covers composed of maximal compatibles, IEEE Trans. Comput. C-20 (1971), 450–452.
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.
Pager, D., Efficient programming techniques for LR(k) parsing, to appear in Comm. ACM.
Pager, D., The Lane Tracing Algorithm for constructing LR(k) parsers, to appear in Comm. ACM.
Pager, D., A time n2 left-to-right parser for context-free grammars, to appear in IEEE Trans. on Computers.
Pager, D., On combining compatible states in LR(k) parsing, Tech. Report PE 257, Information Sciences Program, University of Hawaii, Honolulu, July 1972.
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.
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.
Pager, D., On the decremental approach to left-to-right parsers, to appear in SIAM J. Computing.
Pager, D., On implementing the revised algorithm for eliminating unit reductions, Tech. Report PE 312, Information Sciences Program, University of Hawaii, Honolulu, January 1973.
Pager, D., On eliminating unit reductions from LR(k) parsers, to appear in IEEE Trans. on Computers.
Sperry Rand Corp., UNIVAC 1108 ALGOL, Manual UP-7544, 1967.
Wirth, N., C.A.R. Hoare, A contribution to the development of ALGOL, Comm. ACM 9 (1966), 413–432.
Wirth, N., H. Weber, EULER: a generalization of ALGOL, and its formal definition: Part II, Comm. ACM 9 (1966), 89–99.
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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