Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

求 FIRST 集合溢出 (SLR) #1

Open
ddayzzz opened this issue Dec 7, 2018 · 3 comments
Open

求 FIRST 集合溢出 (SLR) #1

ddayzzz opened this issue Dec 7, 2018 · 3 comments

Comments

@ddayzzz
Copy link

ddayzzz commented Dec 7, 2018

RT

输入:

7
A->E
E->E+T
E->T
T->T*F
T->F
F->(E)
F->i

使用哈工大的编译原理书 P106 的拓广文法 G[E] 把 E' 替换为 A, 输入以上的内容, 出现溢出的问题:
tim 20181207231427

@ddayzzz
Copy link
Author

ddayzzz commented Dec 8, 2018

如果出现了左递归的情况. 如 A->A+T 的情况, 就会溢出。 建议加上求 FIRST 顺序的代码。

@Tachone
Copy link
Owner

Tachone commented Dec 10, 2018

@ddayzzz 学生时代写的啦, 欢迎提PR

@ddayzzz
Copy link
Author

ddayzzz commented Dec 14, 2018

@ddayzzz 学生时代写的啦, 欢迎提PR

哈哈。最近想了想。如果能够先把产生式右部的第一个符号就是终结符就可以先求出。这可能需要一个类似于拓扑排序的顺序来求各个非终结符的 FIRST. 看看能不能写一个 PR。 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants