skip to main content
article
Free Access

Transforming LR(k) Grammars to LR(1), SLR(1), and (1,1) Bounded Right-Context Grammars

Authors Info & Claims
Published:01 July 1976Publication History
Skip Abstract Section

Abstract

A method is presented for directly transforming an arbitrary LR(k) grammar to an equivalent LR(1) grammar. It is further shown that the method transforms an arbitrary prefix-free LR(k) grammar to an equivalent LR(0) grammar. It is argued that the method is efficient and offers some advantages over traditional “look-ahead” parsing methods. Finally, it is demonstrated that the method can be used to transform an LR(1) grammar to an equivalent SLR(1) grammar, which in turn can be easily transformed to an equivalent (1, 1) bounded right-context grammar.

References

  1. 1 AHO, A V , DENNING, P J., AND ULLMAN, J.D Weak and mixed strategy precedence parsing. J ACM 19, 2 (April 1972), 225-243. Google ScholarGoogle Scholar
  2. 2 AHo, A.V , AND ULLMAN, J.D. The Theory of Parszng, Translatwn, and Comphng, Vol. Prentice-Hall, Englewood Cliffs, N.J, 1973. Google ScholarGoogle Scholar
  3. 3 DRMER, F L. Practical translators for LR(k) languages Doctoral DiNs , M I T , Cambridge, Mass, Sept. 1969Google ScholarGoogle Scholar
  4. 4 DEREMR, F.L Simple LR(k) grammars. Comm. ACM 14, 7 (July 1971), 453---460. Google ScholarGoogle Scholar
  5. 5 FLOYD, R W Syntactic analysis and operator precedence J. ACM 10, 3 (July 1963), 316-333 Google ScholarGoogle Scholar
  6. 6 FLOYD, R.W. Bounded-context syntactic analysis Comm. ACM 7, 2 (Feb 1964), 62-67 Google ScholarGoogle Scholar
  7. 7 GELLER, M.M, AND HARRISON, M A Characterizations of LR(0) languages (extended abstract) Proc. of the 14th Ann Symp on Switching and Automata Theory, Iowa City, I a , Oct. 1973, pp. 103-108 (sponsored by IEEE, New York)Google ScholarGoogle Scholar
  8. 8 GINSBURG, S , AND GREIBACH, S A. Deterministic context-free languages. Inform. and Contr. 9 (1966), 620-648.Google ScholarGoogle Scholar
  9. 9 GRAHAM, S.L. Precedence languages and bounded right context languages Doctoral DiNs , Stanford U, Stanford, Calif., July 1971 Google ScholarGoogle Scholar
  10. 10 GRAHAM, S L. On bounded right context languages and grammars. SIAM J. Comput. (1974), 224-254.Google ScholarGoogle Scholar
  11. 11 GRAY, J N , AND HARRISON, M.A On the covering and reduction problems for context-free grammars, J. ACM 19, 4 (Oct. 1972), 675-698 Google ScholarGoogle Scholar
  12. 12 HARRISON, M.A. On the parsing of deterministic languages. Inv:ted presentation, ACM Comput. Sci. Conf, Columbus, Ohio, 1973 (oral presentatmn)Google ScholarGoogle Scholar
  13. 13 HARRISON, M.A, AND HVEL, I.M. Strict determmmtlc grammars J Comput and Syst. Scls. 7 (1973), 237-277Google ScholarGoogle Scholar
  14. 14 HOPCROFT, J.E., AND ULLMAN, J D. Formal Languages and Their Relatzon to Automata Addison-Wesley, Reading, Mass., 1969 Google ScholarGoogle Scholar
  15. 15 ICHBIAH, J.D , AND MORSE, S P A technique for generating almost optimal Floyd-Evans productions for precedence grammars. Comm ACM 13, 8 (Aug. 1970), 501-508. Google ScholarGoogle Scholar
  16. 16 KNUTH, D.E On the translation of languages from left to right. Inform. and Contr. 8 (1965), 607-639.Google ScholarGoogle Scholar
  17. 17 LALONDE, W R An efficmnt LALR parser generator Tech. Rep CSRG-2, U of Toronto, Toronto, Ont , Canada, 1971Google ScholarGoogle Scholar
  18. 18 McAFEE, J., AND PRESSER, L. An algorithm for the design of simple precedence grammars J ACM 19, 3 (July 1972), 385-395. Google ScholarGoogle Scholar
  19. 19 MICKUNAS, M.D User's manual for the PUCSD parser generating system. Tech Rep, Purdue U., West Lafayette, Ind., Aug. 1973.Google ScholarGoogle Scholar
  20. 20 MICKUNAS, M.D Techmques for compressing bounded-context aceeptors. Doctoral DiNs., Purdue U , West Lafayette, Ind , May 1973. Google ScholarGoogle Scholar
  21. 21 MICKUNAS, M D., AND SCHNEIDER, V.B. On the ability to cover LR(k) grammars with LR(1), SLR(1), and (1, 1) bounded-context grammars Proc of the 14th Ann Symp. on Switching and Automata Theory, Iowa City, I a , Oct 1973, pp. 109-121 (sponsored by IEEE, New York).Google ScholarGoogle Scholar
  22. 22 MICKUNAS, M D , XND SCHNEIDER, V.B. A parser-generating system for constructing compressed compilers Comm ACM i6, 11 (Nov. 1973), 669-676 Google ScholarGoogle Scholar
  23. 23 REYNOLDS, J.C., AND HASKELL, R. Grammatical coverings Unpublished manuscript, 1970Google ScholarGoogle Scholar
  24. 24 SCHNEIDER, V.B. A system for designing fast programminglanguage translators Proc.AFIPS 1969 SJCC, Vol. 34, AFIPS Press, Montvale, N J., pp. 777-792.Google ScholarGoogle Scholar
  25. 25 WIRTH, N , AND WEBER, H. EULER: a generalization of ALGOL and its formal defimtlon: Parts I, II. Comm. ACM 9, 1, 2 (Jan , Feb. 1966), 13-23, 25, 89-99f Google ScholarGoogle Scholar

Index Terms

  1. Transforming LR(k) Grammars to LR(1), SLR(1), and (1,1) Bounded Right-Context Grammars

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image Journal of the ACM
          Journal of the ACM  Volume 23, Issue 3
          July 1976
          175 pages
          ISSN:0004-5411
          EISSN:1557-735X
          DOI:10.1145/321958
          Issue’s Table of Contents

          Copyright © 1976 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 1 July 1976
          Published in jacm Volume 23, Issue 3

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader