A new approach to ambiguity of context-free grammars is presented, and
within this approach the LL and LR techniques are generalized to solv
e the following problems for large classes of ambiguous grammars: Cons
truction of a parser that accepts all sentences generated by the gramm
ar, and which always terminates in linear time. Identification of the
structural ambiguity: a finite set of pairs of partial parse trees is
constructed; if for each pair the two partial parse trees are semantic
ally equivalent, the ambiguity of the grammar is semantically irreleva
nt. The user may control the parser generation so as to get a parser w
hich finds some specific parse trees for the sentences. The generalize
d LL and LR techniques will still guarantee that the resulting parser
accepts all sentences and terminates in linear time on all input.