skip to main content
10.1145/1363686.1363747acmconferencesArticle/Chapter ViewAbstractPublication PagessacConference Proceedingsconference-collections
research-article

IELR(1): practical LR(1) parser tables for non-LR(1) grammars with conflict resolution

Published:16 March 2008Publication History

ABSTRACT

There has been a recent effort in the literature to reconsider grammar-dependent software development from an engineering point of view. As part of that effort, we examine a deficiency in the state of the art of practical LR parser table generation. Specifically, LALR sometimes generates parser tables that do not accept the full language that the grammar developer expects, but canonical LR is too inefficient to be practical. In response, many researchers have attempted to develop minimal LR parser table generation algorithms. In this paper, we demonstrate that a well known algorithm described by David Pager and implemented in Menhir, the most robust minimal LR(1) implementation we have discovered, does not always achieve the full power of canonical LR(1) when the given grammar is non-LR(1) coupled with a specification for resolving conflicts. We also outline an original minimal LR(1) algorithm, IELR(1), which we have implemented as an extension of GNU Bison and which does not exhibit this deficiency. Finally, using our implementation, we demonstrate the relevance of this deficiency for several real-world grammars, and we show that our implementation is feasible for generating minimal LR(1) parsers for those grammars.

References

  1. Bison. The GNU Project. http://www.gnu.org/software/bison/.Google ScholarGoogle Scholar
  2. Gawk. The GNU Project. http://www.gnu.org/software/gawk/.Google ScholarGoogle Scholar
  3. GCC. The GNU Project. http://gcc.gnu.org/.Google ScholarGoogle Scholar
  4. Groff. The GNU Project. http://www.gnu.org/software/groff/.Google ScholarGoogle Scholar
  5. {Groff} parsing a corner specification. Groff mailing list archives. http://lists.gnu.org/archive/html/groff/2007-08/msg00051.html.Google ScholarGoogle Scholar
  6. LRGen. P. B. Mann. http://www.paulbmann.com/lrgen/.Google ScholarGoogle Scholar
  7. Menhir. F. Pottier and Y. Régis-Gianas. http://cristal.inria.fr/~fpottier/menhir/.Google ScholarGoogle Scholar
  8. The Honalee LR(k) Algorithm. D. R. Tribble. http://david.tribble.com/text/honalee.html.Google ScholarGoogle Scholar
  9. Valgrind. http://www.valgrind.org/.Google ScholarGoogle Scholar
  10. International Standard, Programming Languages - C++. Number ISO/IEC 14882:2003(E). American National Standards Institute, October 2003.Google ScholarGoogle Scholar
  11. Single UNIX Specification, Version 3. The IEEE and the Open Group, April 2004. http://www.opengroup.org/bookstore/catalog/t041.htm.Google ScholarGoogle Scholar
  12. A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles, Techniques, and Tools. Addison-Wesley, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Ralph Corderoy. troff.org, The Text Processor for Typesetters. http://troff.org.Google ScholarGoogle Scholar
  14. Joel E. Denny. http://joeldenny.org.Google ScholarGoogle Scholar
  15. F. DeRemer and T. Pennello. Efficient Computation of LALR(1) Look-Ahead Sets. ACM Transactions on Programming Languages and Systems, 4(4):615--649, October 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. The GNU Project. Bison, 2.3 edition, May 2006.Google ScholarGoogle Scholar
  17. S. Johnson. Yacc: Yet Another Compiler Compiler. In UNIX Programmer's Manual, volume 2, pages 353--387. Holt, Rinehart, and Winston, New York, NY, USA, 1979.Google ScholarGoogle Scholar
  18. P. Klint, R. Lämmel, and Chris Verhoef. Toward an engineering discipline for grammarware. ACM Transactions on Software Engineering Methodology, 14(3):331--380, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. R. Lämmel. Grammar Testing. In FASE, pages 201--216, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. D. Pager. The lane tracing algorithm for constructing LR(k) parsers. In STOC '73: Proceedings of the fifth annual ACM symposium on Theory of computing, pages 172--181, New York, NY, USA, 1973. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. D. Pager. A Practical General Method for Constructing LR(k) Parsers. Act Informatica, 7(3):249--268, September 1977.Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. D. Pager. The Lane-Tracing Algorithm for Constructing LR(k) Parsers and Ways of Enhancing Its Efficiency. Information Sciences, 12(1):19--42, 1977.Google ScholarGoogle ScholarCross RefCross Ref
  23. P. Pepper. LR Parsing = Grammar Transformation + LL Parsing, Making LR Parsing More Understandable And More Efficient. Technical Report 99--05, TU Berlin, 1999.Google ScholarGoogle Scholar
  24. D. Spector. Full LR(1) parser generation. SIGPLAN Not., 16(8):58--66, 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. D. Spector. Efficient full LR(1) parser generation. SIGPLAN Not., 23(12):143--150, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. M. van den Brand and E. Visser. Generation of formatters for context-free languages. ACM Trans. Softw. Eng. Methodol., 5(1):1--41, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. M. G. J. van den Brand, A. Sellink, and C. Verhoef. Current Parsing Techniques in Software Renovation Considered Harmful. In IWPC, page 108, Washington, DC, USA, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. IELR(1): practical LR(1) parser tables for non-LR(1) grammars with conflict resolution

      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
      • Published in

        cover image ACM Conferences
        SAC '08: Proceedings of the 2008 ACM symposium on Applied computing
        March 2008
        2586 pages
        ISBN:9781595937537
        DOI:10.1145/1363686

        Copyright © 2008 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 16 March 2008

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate1,650of6,669submissions,25%

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader