In this chapter, we present a very general way of formulating of parsing algorithms, known as the parsing as deduction approach. For context-free grammars, the parsing problem always involves a search over the possible derviation trees for a particular string, given a grammar. Under the parsing as deduction approach, we separate the order of this search, from it’s logical characteristics. We do this by viewing parsing as a kind of logical deduction, starting from some axioms and proceeding to prove a theorem, called a goal. A parsing as deduction specification of a parsing algorithm has three components:

  1. A specification of the format of items. These items indicate statements about the space of possible derivations that have been proven by the system so far.

  2. A specification of a set of axioms. These axioms represent the starting statements that do not need to be proved.

  3. A specification of a set of goals. These represent the statements about the set of derivations that we are trying to prove.

  4. A specification of a set of inference rules which provide rules on how to go from already proven items to new items.

These components are best illustrated by example. Below we give an overview of four popular algorithms. Throughout these examples, we will use the following grammar.

And the following sentence and valid derivation tree under this grammar.

Recursive Descent Parsing

Our first algorith, is known as recursive decent parsing and is a simplest top-down, depth first algorithm for parsing CFGs.

Here is an example of a set of deductions that lead to a valid parse of the example sentence above.

Shift Reduce Parsing

Here is an example of a set of deductions that lead to a valid parse of the example sentence above.

Earley Parsing

Here is an example of a set of deductions that lead to a valid parse of the example sentence above.


43 Parsing Context-Free Grammars 45 Chomsky Normal Form and CYK Parsing