如何确定该语法中 E 的第一组?
我想知道如何用语法确定 E 的 FIRST
集:
E -> XYE | e
X -> x
Y -> y
任何人都可以给我一些指导吗?
I wonder how to determine the FIRST
set of E with grammar:
E -> XYE | e
X -> x
Y -> y
Can anyone give me some direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,假设您从 E 开始,那么第一个终端是 x 通过 E→XYE 产生式(因为 X总是产生x)或者通过E→e产生e。所以 First(E) = {x,e}。
这看起来很简单...
Well, assuming that you're starting with E, then either the first terminal is x via the E→XYE production (since X always produces x) or it is e via the E→e production. So First(E) = {x,e}.
That seems pretty straightforward...
对待形式A的规则-> ...x... | ...你....
两条规则 A -> ...x...和B-> ...y...
形成一个集合S,最初包含形式为E->的规则。 ....
然后
当循环终止时,F 包含以下标记:
是第一个(F)。
这没有考虑空生产。
Treat rules of the form A -> ...x... | ...y ....
as two rules A -> ...x... and B -> ...y...
Form a set S initially containing rules of form E-> ....
then
WHen the loop terminates, F contains the tokens which
are the First(F).
This does not take into account empty productions.