In this paper we propose and evaluate a method for locating causes of ambiguity in context-free grammars by automatic analysis of parse forests. A parse forest is the set of parse trees of an ambiguous sentence. % an output of a static ambiguity detection tool that has detected ambiguity in a context-free grammar or of a general parser that has accidentally parsed an ambiguous sentence. Deducing causes of ambiguity from observing parse forests is hard for grammar engineers because of (a) the size of the parse forests, (b) the complex shape of parse forests, and (c) the diversity of causes of ambiguity. We first analyze the diversity of ambiguities in grammars for programming languages and the diversity of solutions to these ambiguities. Then we introduce \drambiguity: a parse forest diagnostics tools that explains the causes of ambiguity by analyzing differences between parse trees and proposes solutions. We demonstrate its effectiveness using a small experiment with a grammar for Java 5.

, , , ,
, , ,
Springer
J. Saraiva , U. Aßmann , A.M. Sloane
GrammarLab: Foundations of a Grammar Laboratory
International Conference on Software Language Engineering
Software Analysis and Transformation

Basten, B., & Vinju, J. (2011). Parse Forest Diagnostics with Dr. Ambiguity. In J. Saraiva, U. Aßmann, & A. M. Sloane (Eds.), Proceedings of the Fourth International Conference on Software Language Engineering (SLE 2011). Springer.