Building an LR(1) MachineTopComputing Follow(N)LR(1) Parsing

LR(1) Parsing

  1. Simply using Follow sets to interpret look ahead symbols may give less information than is really available.
  2. LR(1) parsing is a generalization of LR(0) parsing that keeps track of both what points in what productions we might be up to and what might follow the rhs's of the productions we are working on.
  3. We start with plenty of new (but familiar) definitions.
    LR(1) item
    Given a grammar G, we say that [ N 1 . 2 , a ] is an LR(1) item or LR(1) configuration for G if N 1 2 is a production in G and a ( Vt U ). The symbol `a' is called the lookahead.
    Configuration Set
    We will refer to a set of LR(1) items as an LR(1) configuration set.
    Valid item
    Given a grammar G, we say that an LR(1) item [ N 1 . 2, a ] is valid for ( Vn U Vt )* if there is a rightmost derivation
    S N omega 1 2 omega
    such that 1 = and a First(omega).

Computer Science 434
Department of Computer Science
Williams College

Building an LR(1) MachineTopComputing Follow(N)LR(1) Parsing