Faster ambiguity detection by grammar filtering

Bas Basten, Jurgen J. Vinju. Faster ambiguity detection by grammar filtering. In Claus Brabrand, Pierre-Etienne Moreau, editors, Proceedings of the of the Tenth Workshop on Language Descriptions, Tools and Applications, LDTA 2010, Paphos, Cyprus, March 28-29, 2010 - satellite event of ETAPS. pages 5, ACM, 2010. [doi]


Real programming languages are often defined using ambiguous context-free grammars. Some ambiguity is intentional while other ambiguity is accidental. A good grammar development environment should therefore contain a static ambiguity checker to help the grammar engineer. Ambiguity of context-free grammars is an undecidable property. Nevertheless, various imperfect ambiguity checkers exist. Exhaustive methods are accurate, but suffer from non-termination. Termination is guaranteed by approximative methods, at the expense of accuracy. In this paper we combine an approximative method with an exhaustive method. We present an extension to the Noncanonical Unambiguity Test that identifies production rules that do not contribute to the ambiguity of a grammar and show how this information can be used to significantly reduce the search space of exhaustive methods. Our experimental evalua- tion on a number of real world grammars shows orders of magnitude gains in efficiency in some cases and negligible losses of efficiency in others.