CS606 Assignment 3 Solution Spring 2021 | CS606 Assignment No. 3 100% Correct Solution by Mustakbil Corner
Following is the Question
Question:
Consider the following CFG.
S ®tTd | fFd | tFe | fTe
T ®a
F ® a
For above grammar construct the canonical collection for LR(1) items.
For solution please
It is requested to you to please subscribe our Blog for latest updates
STEP 1 : Subscribe
STEP 2
Cs606 Assignment 3 Solution BY Mustakbil Corner
Question:
Consider the following CFG.
S ®tTd | fFd | tFe | fTe
T ®a
F ® a
For above grammar construct the canonical collection for LR (1) items.
Solution
Add augment production, insert . (Dot) symbol at the first position for every Production of “G”. Also add the look ahead.
S` à.S , $
I0 State :
Add augment production to the I0 State and compute the closure
I0 = closure (S` à.S )
Add all production starting with “S” in I0 State because “.” Is followed by non-terminal, So the I0 State becomes
S à.S , $
S à.tTd , $
S à.fFd , $
S à.tFe , $
S à.fTe , $
I1 = Go to ( I0 , S ) = S` àS. , $ (Accepting State)
I2 = Go to ( I0 , t ) = S àt.Td , $
Add all production starting with small “t” in I2 State because “.” Is followed by non-terminal.
So, the I2 State becomes
I2 = S à.tTd , $
S à.tTd , $
S à t.Fe , $
T à.a , d
F à.b , e
I3 = Go to ( I0 , f ) = S àf .Fd , $
Add all production starting with small “f” in I3 State because “.” Is followed by non-terminal.
So, the I3 State becomes
I3 = S à f .Fd , $
S àf .Te , $
T à.a , e
F à.b , d
I4 = Go to ( I2 , T ) = Closure ( S àtT . d ,$ ) = S àtT . d ,$
I5 = Go to ( I2 , F ) = Closure ( S àtF . e ,$ ) = S àtF . e ,$
I6 = Go to ( I2 , a ) = Closure ( T àa ., d ) = T àa ., d
I7 = Go to ( I3 , F ) = Closure ( F àb ., e ) = F àb ., e
I8 = Go to ( I2 , b ) = Closure ( S àfF .d , $ ) = S àfF .d , $
I9 = Go to ( I3 , T ) = Closure ( S àfT . e ,$ ) = S àfT . e ,$
I10 = Go to ( I3 , a ) = Closure ( T àa ., e ) = T àa ., e (*)
I11 = Go to ( I3 , b ) = Closure ( F àb ., d ) = F àb ., d (*)
I12 = Go to ( I4 , d ) = Closure ( S àtTd ., $ ) = S àtTd ., $ (*)
I13 = Go to ( I5 , e ) = Closure ( S àtFe ., $ ) = S àtFe ., $ (*)
I14 = Go to ( I8 , F ) = Closure ( S àtFd ., $ ) = S àtFd ., $ (*)
I15 = Go to ( I9 , e ) = Closure ( S àfTe ., $ ) = S àfTe ., $ (*)
This is 100% Correct Solution
NOTE: Do not Copy Make your Own
If you have any suggestion please contact us
0 Comments
If you have any queries please drop in your comments.