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.