0

I understand the concept of LR(1) parsing and lookahead symbols. I have the solution to the exercise and it does not agree with my solution.

I'm trying to fill the LR(1) parsing table for the grammar below:

S->xAz 
S->BAx
A->Ay
A->e
B->yB
B->y

Ι don't have to extend the grammar since S does not appear in any right hand side of any rule.

First(A)=y,e
First(Ax)=x,y
First(B)=y
First(Ay)=y

Lookahead symbols in brackets.

So, I0 = Closure(S->.xAz($) , S->.BAx($) ) =

S->.xAz($)
S->.BAx($)
B->.yB(x,y)
B->.y(x,y)

When i try GOTO(0,x) i think that i should go to:

S->x.Az($)
A->.Ay(z)
A->. (z) 

To find the lookahead symbol for A->. & A->.Ay i take First(z). But the official book solution says the lookeahead is (z,y). Where does that y comes from?

Thank you in advance

user207421
  • 305,947
  • 44
  • 307
  • 483
Nikos
  • 23
  • 3

0 Answers0