Spread Knowledge

CS606 - Compiler Construction - Lecture Handout 26

User Rating:  / 0

Related Content: CS606 - VU Lectures, Handouts, PPT Slides, Assignments, Quizzes, Papers & Books of Compiler Construction

The initial DFA state I0 we computed is the ε-closure of the set consisting of item

S → •E

Recall the stage in the closure

s = { [S → •E, $] , [E → •E + (E), $] , [E → •int, $] }

The NFA states and transitions required are

The NFA states and transitions required are


Construction of collection of canonical sets of LR(1) items.
An augmented grammar G'
Collection of canonical (CC) sets of LR(1)


We use the algorithm to compute the sets of LR(1) items for the augmented grammar G'

S → E
E → E + (E) | int

We computed I0; we now compute the sets goto(I0,X) for various values of X. X can be E, int, +, ( and ) .

I1 = goto(I0,int): invokes closure({[E → int•,$/+]}). No additional closure is possible since the dot is at the right end of the production. Thus I1 = {[E → int•, $/+]} and we have the transition from I0 to I1 on int

transition from

terminal + appears

and so on. The sets and transitions so far yield the DFA

yield the DFA