Paul Klint, Eelco Visser. Using Filters for the Disambiguation of Context-free Grammars. Technical Report P9426, Programming Research Group, University of Amsterdam, October 1994.
An ambiguous context-free grammar defines a language in which some sentences have multiple interpretations. For conciseness, ambiguous context-free grammars are frequently used to define even completely unambiguous languages and numerous disambiguation methods exist for specifying which interpretation is the intended one for each sentence. The existing methods can be divided in
parser specific' methods that describe how some parsing technique deals with ambiguous sentences andlogical’ methods that describe the intended interpretation without reference to a specific parsing technique. We propose a framework of \em filters/ to describe and compare a wide range of disambiguation problems in a parser-independent way. A filter is a function that selects from a set of parse trees (the canonical representation of the interpretations of a sentence) the intended trees. The framework enables us to define several general properties of disambiguation methods. The expressive power of filters is illustrated by several case studies. Finally, a start is made with the study of efficient implementation techniques for filters by exploiting the commutativity of parsing steps and filter steps for certain classes of filters.