LR(1)项的讨论:含义?
什么是规范的 LR(1) 项!我读过龙书,它让我困惑,(delta,gamma,toh,...)
有人可以帮助我解决这个问题吗?
这个英文是什么意思? [A-> alpha.Bbeta , a]
非常感谢..
What is the canonical LR(1) items ! I have read the Dragon Book, It confuses Me , (delta,gamma,toh,...)
Can Someone help me with this issue ?
What is this meaning in English? [A - > alpha.Bbeta , a]
Thanks a lot..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
<代码>[A->阿尔法。 B beta , a] 基本上意味着“假设规则
A
正在扩展,到目前为止我们已经看到了alpha
。然后我们期望看到B beta
。我们还知道,在A
之后,我们将看到一个a
”因此,在 CLR(1) 中,您的状态由其中一些组成。项目。然后您有很多选择:
first(B)
的成员,并假设您有诸如B->gamma C
的规则>,然后你可以“转移”并进入包含[B ->; 的状态伽玛。 C,测试版]
。如您所见,.
已移动超过gamma
(因为gamma
已匹配,并且B
的后续内容为beta
因为这是规则A -> alpha B beta
中B
之后的内容,a<。 /code> 并假设
B beta
可以生成lambda
(空字符串)(这里,假设 beta 是一个可以生成lambda
的非终结符),然后,您可以“减少”并进入包含诸如以下规则的状态。C -> Something A . a Something_else,follow]
在这种情况下,您已决定alpha
、B
和。 beta
堆栈上的可以归为一A
这是我可以解释的最简单的方式。
[A -> alpha . B beta , a]
basically means "assuming ruleA
was being expanded, so far we have seenalpha
. We then expect to seeB beta
. We also know that afterA
, we are going to see ana
"So, in CLR(1), you have states consisting of some of these items. You then have many options:
first(B)
, and assuming you have a rule such asB->gamma C
, then you can "shift" and go to a state containing[B -> gamma . C, beta]
. As you can see, the.
has moved passedgamma
(becausegamma
is matched and the follow ofB
isbeta
because that's what came afterB
in the ruleA -> alpha B beta
.a
and assumingB beta
could generatelambda
(empty string) (here, assume beta is a nonterminal that can generatelambda
). Then, you can "reduce" and go to a state that contains rules such asC -> something A . a something_else, follow]
. In this case, you have decided that thealpha
,B
andbeta
on the stack can be grouped into oneA
.That was the simplest way I could explain this.
IIRC,这是一个“项”,即某种句子形式解析的潜在状态。
这意味着:
当尝试解析可被视为非终结符 A 的(目标语言的子字符串)时,是否已看到 alpha,并且 ( ".") 预计接下来是 Bbeta,并且如果看到非终结符的元素,则如果下一个标记是 a<,则它是有效的 A /强>。
(我认为你把Bbeta抄错了,书里可能是beta)。
IIRC, this is an "item", that is, the potential state of some sentential form parse.
What this means:
is that when attempting to parse a (substring of the target language) which can be considerat as the nonterminal A, is the alpha has been seen, and (".") that Bbeta is expected next, and that if the elements of the nonterminal are seen, it is a valid A if the next token is a.
(I think you transcribed Bbeta wrong, it was probably beta in the book).