Massaging GrammarsTop Top-down ParsingBottom-up Parsing

Bottom-up Parsing

  1. Recall that in a bottom-up parser, we repeatedly simplify sentential forms (starting with the input) by replacing the right hand side of a production by the left hand side.
  2. One cannot always parse bottom-up by simply reducing as soon as one can match the right hands side of a production.

  3. Assuming that the string being considered is a sentential form, the correct string to reduce is the handle as defined by:

    simple phrase
    Given a grammar G and a string w = such that

    1. w, , , (Vn U Vt)* ,

    2. for some U Vn, U P and U is a sentential form of G
    we say that is a simple phrase of the sentential form w.

    handle
    The leftmost simple phrase of a sentential form is called the handle.

  4. The problem one must solve to construct a bottom-up parser is to find rules for determining when one is looking at the handle.

  5. The class of grammars for which one can parse bottom-up deterministically (i.e. in without backup) looking ahead at most k characters at each step is called the class of LR(k) grammars.

Computer Science 434
Department of Computer Science
Williams College

Massaging GrammarsTop Top-down ParsingBottom-up Parsing