Canonical LR Parsing
. Carry extra information in the state so that wrong reductions by A
α will be ruled out
. Redefine LR items to include a terminal symbol as a second component (look ahead symbol)
. The general form of the item becomes [A
α . ß , a] which is called LR(1) item.
. Item [A
α ., a] calls for reduction only if next input is a. The set of symbols
Canonical LR parsers solve this problem by storing extra information in the state itself. The problem we have with SLR parsers is because it does reduction even for those symbols of follow(A) for which it is invalid.
So LR items are redefined to store 1 terminal (look ahead symbol) along with state and thus, the items now are LR(1) items.
An LR(1) item has the form : [A
a . ß , a] and reduction is done using this rule only if input is 'a'. Clearly the symbols a's form a subset of follow(A).