Chapter 4: Syntax Analysis

LALR Parse table

. Look Ahead LR parsers

. Consider a pair of similar looking states (same kernel and different lookaheads) in the set of LR(1) items

I 4 : C d. , c/d I7 : C d., $

. Replace I4 and I7 by a new state I 47 consisting of (C d., c/d/$)

. Similarly I 3 & I6 and I 8 & I 9 form pairs

. Merge LR(1) items having the same core

We will combine Ii and Ij to construct new Iij if Ii and Ij have the same core and the difference is only in look ahead symbols. After merging the sets of LR(1) items for previous example will be as follows:

I0 : S' S $

S .CC $

C .cC c/d

C .d c/d

I1 : goto(I 0 ,S)

S' S. $

I2 : goto(I 0 ,C)

S C.C $

C .cC $

C .d $

I36 : goto(I 2 ,c)

C c.C c/d/$

C .cC c/d/$

C .d c/d/$

I4 : goto(I 0 ,d)

C d. c/d

I 5 : goto(I 2 ,C)

S CC. $

I7 : goto(I 2 ,d)

C d. $

I 89 : goto(I 36 ,C)

C cC. c/d/$