Awesome q2a theme
0 votes
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

in Compiler Design by (415 points) | 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. (:

1 Answer

0 votes
Best answer
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. $[2]$ 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. [5] 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 by
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.
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
Welcome to GATE CSE Doubts, where you can ask questions and receive answers from other members of the community.
Top Users Feb 2020
  1. shashin

    363 Points

  2. Shaik Masthan

    79 Points

  3. SuvasishDutta

    39 Points

  4. srestha

    33 Points

  5. Mk Utkarsh

    32 Points

  6. neeraj_bhatt

    31 Points

  7. !KARAN

    30 Points

  8. Debapaul

    23 Points

  9. Pratyush Priyam Kuan

    18 Points

  10. kalra05

    18 Points

Monthly Top User and those within 60% of his/her points will get a share of monthly revenue of GO subject to a minimum payout of Rs. 500. Current monthly budget for Top Users is Rs. 75.
3,327 questions
1,581 answers
10,280 comments
89,915 users