7.1. Parsers

Suppose that G is a grammar. The parsing problem for G is: given a sequence α of tokens, find a parse tree or derivation of α.

A parser for G is an algorithm (or program) that solves the parsing problem for G.

A parser does not directly produce a parse tree or a derivation as a data structure, although semantic rules attached to the parser can do that during the parsing process.

A parser finds a derivation implicitly. Equivalently, it traverses an implicit parse tree.

But the easiest way to understand what a parser is doing is to imagine that it builds a parse tree up as it goes.