Let G be any grammar with the following productions:

X → X + Y | Y

Y → Y * Z | Z

Z → (X)

Z → id

If LR(!) parser is used to parse the above grammar, then total how many look-a-heads are present for the item X → >Y and Z → .id in the initial state _____________.

Actually we have 3 different lookaheads as it is specified how many lookaheads the answer should be 5 if it is specified how many different lookaheads then answer will be 3.

Am I correct?

0

but hemanth it is asking for particular items right? so it will still different for both the items .isnt so?

0

@adarsh_1997Yes you are right. After seeing the answer I just thought in what way the answer could be 3.

0

It is a duplicate question

Answer is 5

X-->.Y{$$,+}

Z--> .id{$,+,*}

0

5 will be the answer. The answer in ME test is 3 which is wrong

{+,\$,*} as Look Ahead for Z->.id

and {\$,+} for X→.Y

+1

The answer is 5. They have provided wrong answer.

+1

Yeah it should be $5$. 2 for $X \rightarrow .Y$ and 3 for $Z \rightarrow .id$.

0

yes that's what i've got but i don't know why they incorrect the 5.

+1

@ghostman23111 madeeasy have 1 solution incorrect for almost every test. so better trust your intuition and judgement.

+1

2 +3 = 5

for X->.Y +/\$

for Z->.id */+/\$

0

This question is from made easy test na??. But I think they have given wrong answer