Chapter 4: Syntax Analysis

Construct SLR parse table

. Construct C={I0 , . , In } the collection of sets of LR(0) items

. If A α .a ß is in Ii and goto(Ii , a) = Ij then action[i,a] = shift j

. If A a . is in Ii

then action[i,a] = reduce A a for all a in follow(A)

. If S' S. is in Ii then action[i,$] = accept

. If goto(I i ,A) = Ij then goto[i,A]=j for all non terminals A

. All entries not defined are errors

The SLR parse table is constructed for parser states (I0 to In ) against terminal and non terminal symbols . For terminals, entries are referred as 'action' for that state and terminal, while for non terminal, entries are 'goto' for state and non terminal. The way entries are filled is :

. If A α .a ß is in Ii and goto(Ii , a) = I j where a is a terminal then action[i, a] = shift j.

. If A α . is in Ii where a is a string of terminals and non terminals then action[i, b] = reduce A a for all b in follow(A).

. If S' S. is in Ii where S' is symbol introduced for augmenting the grammar then action[i, $] = accept.

. If goto(Ii , A) = Ij where A is a non terminal then goto[i, A] = j.

. The entries which are not filled are errors.