In order to construct the sets of items for an parser, we just need to make three modifications:
Since we are only interested in finding and reducing it
to as a kind of a "sub-goal" of finding , we can
state that after reducing to , the next input symbol should
match whatever is derived from ; ie. it should be in
. If can derive , then the
next input symbol should match what had previously been expected
to follow , ie. the lookahead symbol `a'.
Thus:
contains all items of the form
, where `b' is a terminal in
The algorithm for constructing a handle-recognising DFA is exactly the
same as before, except that we use the above modifications.
One result of these changes is to increase the number of possible items, and also the number of likely states in the handle-recognising DFA; thus parsing tables for a grammar tend to be significantly larger than the or tables for the same grammar.
However, the parsing is improved, because now we can modify the
reduction rule to get:
The LR(1) reduction rule:
Since the number of `a' symbols may be smaller than , there can be less reductions in an parse table, and thus less potential conflicts.