28 views Hello all, I have been trying to understand how to add look aheads in cannonical collection of LR(1) items:

This is my approach:

It asked for the items in closure of S’→.S,$(calling it P1) Now since . is present before S, I need to write closure of S. S→.SaA |.aSc |.A The lookaheads for the above productions should be First(whatever is present after S in P1) ie.$

So,

S→.SaA, $|.aSc,$

|.A, $Also have to write closure of A A→.Sb,$

|.d, $I am unable to figure out how to get a, b in lookaheads, I am only getting$. Any help is appreciated. Thank you

| 28 views
+1
Dont even try attempt LR(1) and LALR(1) parsing in exam(though they are never asked). This is where most people will lose marks. I know after this comment many will oppose me saying that u should try. But, better be safe than sorry. Moreover they do not ask LALR(1) and LR(1) parsing tables in gate
0
Ya it’s lengthy and confusing. I won’t say confusing but with the clock ticking beside even 1+1 is confusing. Anyway can you tell what I did wrong? Since this is a short question..
0
i am currently outside, will surely try when i reach home at night..
0

No worries take your time. Could also check https://csedoubts.gateoverflow.in/5333/computer-networks-ace-test-series-fragmentation-doubt . I got two answers wrong back to back. :(

0
I think these type of questions can be kept for last pass. If we have time remaining at last we can attempt it. And these question is not particularly that hard(Agree that this is tricky but if we double check each options then it can be done correctly) as there are questions on counting cache misses given a program fragment which requires hell lot of time. (:

Answer given is correct which is $(D)$.

This is tricky btw.

Solution is as follow:

1] $S’ \rightarrow .S, \{\$\}$2]$S \rightarrow .SaA, \{\$\}$

3] $S \rightarrow .aSc, \{\$\}$4]$S \rightarrow .A, \{\$\}$

5] $A \rightarrow .Sb, \{\$\}$6]$A \rightarrow .d, \{\$\}$

now, because of item no. $$ we have to add following items.

7] $S \rightarrow .SaA, \{a\}$

8] $S \rightarrow .aSc, \{a\}$

9] $S \rightarrow .A, \{a\}$

10] $A \rightarrow .Sb, \{a\}$

11] $A \rightarrow .d, \{a\}$

and now because of item no.  we have to add following items.

12] $S \rightarrow .SaA, \{b\}$

13] $S \rightarrow .aSc, \{b\}$

14] $S \rightarrow .A, \{b\}$

15] $A \rightarrow .Sb, \{b\}$

16] $A \rightarrow .d, \{b\}$

Now combining all those items into one set which is exactly what is given in your test series answer. This time test series answer is right. (:.
by (911 points)
selected
0
I think I should have accepted by now that I’m a dumb piece of shit…
0
It's not like that bro. I have made mistake in this question itself while solving this.

Some topics are difficult for most student but enough practice will do the work.

Point is every time you make mistake you have to remember that mistake and try to not repeat it again.