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.
- Bison. The GNU Project. http://www.gnu.org/software/bison/.Google Scholar
- Gawk. The GNU Project. http://www.gnu.org/software/gawk/.Google Scholar
- GCC. The GNU Project. http://gcc.gnu.org/.Google Scholar
- Groff. The GNU Project. http://www.gnu.org/software/groff/.Google Scholar
- {Groff} parsing a corner specification. Groff mailing list archives. http://lists.gnu.org/archive/html/groff/2007-08/msg00051.html.Google Scholar
- LRGen. P. B. Mann. http://www.paulbmann.com/lrgen/.Google Scholar
- Menhir. F. Pottier and Y. Régis-Gianas. http://cristal.inria.fr/~fpottier/menhir/.Google Scholar
- The Honalee LR(k) Algorithm. D. R. Tribble. http://david.tribble.com/text/honalee.html.Google Scholar
- Valgrind. http://www.valgrind.org/.Google Scholar
- International Standard, Programming Languages - C++. Number ISO/IEC 14882:2003(E). American National Standards Institute, October 2003.Google Scholar
- Single UNIX Specification, Version 3. The IEEE and the Open Group, April 2004. http://www.opengroup.org/bookstore/catalog/t041.htm.Google Scholar
- A. V. Aho, R. Sethi, and J. D. Ullman. Compilers: Principles, Techniques, and Tools. Addison-Wesley, 1986. Google ScholarDigital Library
- Ralph Corderoy. troff.org, The Text Processor for Typesetters. http://troff.org.Google Scholar
- Joel E. Denny. http://joeldenny.org.Google Scholar
- 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 ScholarDigital Library
- The GNU Project. Bison, 2.3 edition, May 2006.Google Scholar
- 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 Scholar
- 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 ScholarDigital Library
- R. Lämmel. Grammar Testing. In FASE, pages 201--216, 2001. Google ScholarDigital Library
- 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 ScholarDigital Library
- D. Pager. A Practical General Method for Constructing LR(k) Parsers. Act Informatica, 7(3):249--268, September 1977.Google ScholarDigital Library
- 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 ScholarCross Ref
- P. Pepper. LR Parsing = Grammar Transformation + LL Parsing, Making LR Parsing More Understandable And More Efficient. Technical Report 99--05, TU Berlin, 1999.Google Scholar
- D. Spector. Full LR(1) parser generation. SIGPLAN Not., 16(8):58--66, 1981. Google ScholarDigital Library
- D. Spector. Efficient full LR(1) parser generation. SIGPLAN Not., 23(12):143--150, 1988. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
Index Terms
- IELR(1): practical LR(1) parser tables for non-LR(1) grammars with conflict resolution
Recommendations
The IELR(1) algorithm for generating minimal LR(1) parser tables for non-LR(1) grammars with conflict resolution
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. ...
A translational BNF grammar notation (TBNF)
BNF grammar notation came into existence about 1960 for the specification of programming languages. It was first used for the automatic generation of parsers about 1972. BNF was later replaced with EBNF offering regular expression notation in the right ...
Comments