Chapter 4:Syntax Analysis

SLR parse table for the grammar

The table has multiple entries in action[2,=]

Using the rules given for parse table construction and above set of LR(0) items, parse table as shown can be constructed. For example:

Consider [6,*] : I6 contains L .*R and goto (I 6 , *) = I 4. So [6,*] = shift 4 or s4.

Consider [4,L] : goto(I4 , L) = I 8. So [4,L] = 8.

Consider [7,=] : I7 contains L *R. and ' = ' is in follow(L).

So [7,=] = reduce L *R or r4 i.e. reduce by 4th rule.

Similarly the other entries can be filled .

Consider the entry for [2,=]

I 2 contains S L.=R and goto(I2 , =) = I 6. So [2,=] contains 'shift 6'.

I2 contains R L. and '=' is in follow(R).

So [2,=] contains 'reduce 6'. So [2,=] has multiple entries viz. r6 and s6.