monimm / llandlr Goto Github PK
View Code? Open in Web Editor NEWLL(0)和SLR(1)语法分析Java实现
LL(0)和SLR(1)语法分析Java实现
bug1、对于某些文法,求非终结符的FIRST集,空指针出错
ans:断点调试后发现,是因为在执行getFollow函数时,调用的getFirst(right);,是求串的FIRST集,在getFirst函数中,直接调用了firstSet.get(tn);,但是tn的FIRST集有可能没有事先求出,所以在前面加上 if(!firstSet.containsKey(tn) { getFirst(tn); } 即可
bug2、对于某些比较复杂一点的文法,还是会存在“求出的FOLLOW集不完整”的现象,比如如下文法:
S->I|o
I->i(E)SL
L->eS|ε
E->a|b
代码改动如下:
public String [] inputExperssion = { "S->I", "S->o", "I->i(E)SL", "L->eS", "L->~", "E->a", "E->b"};
public String strInput = "i(a)i(b)oeo$";
public Character S = 'S';
analyzeStatck.push('S');
按照您的代码,求出的FOLLOW集情况如下:
Follow S: $ e
Follow E: )
Follow I: $
Follow L: $
但是,我们知道,正确的是这样:
Follow S: $ e
Follow E: )
Follow I: $ e
Follow L: $ e
也就是说会发生不完整的现象。
ans:本人目前也不知如何解决,希望楼主看看~~
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.