[英]LR(1) parsing, problem with look ahead symbols
I understand the concept of LR(1) parsing and lookahead symbols.我了解LR(1)解析和超前符号的概念。 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:我正在尝试为以下语法填充LR(1)解析表:
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.我不必扩展语法,因为S不会出现在任何规则的任何右侧。
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($) ) =因此,I0 =闭包(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:当我尝试GOTO(0,x)时,我认为我应该去:
S->x.Az($)
A->.Ay(z)
A->. (z)
To find the lookahead symbol for A->.查找A->的超前符号。 & A->.Ay i take First(z). &A->。Ay我选First(z)。 But the official book solution says the lookeahead is (z,y).但是官方的书籍解决方案说,前瞻是(z,y)。 Where does that y comes from? y是从哪里来的?
Thank you in advance先感谢您
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.