欢迎来到天天文库
浏览记录
ID:36441658
大小:88.50 KB
页数:17页
时间:2019-05-10
《LL(I)文法的预测分析》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、LL(1)文法的预测分析2008-12-0522:27//edge.h#ifndefHEAD_EDGE#defineHEAD_EDGE#includeusingnamespacestd;externintSUM;externstringNODE,ENODE;classedge{public:edge();stringgetlf();stringgetrg();stringgetfirst();stringgetfollow();stringgetselect();stringge
2、tro();intgetrlen();voidnewfirst(stringw);voidnewfollow(stringw);voidnewselect(stringw);voiddelfirst();private:stringleft,right,first,follow,select;intrlen;};#endif///////////////////////////////////////////////////////////////////////////////edge.cpp
3、#include#include"edge.h"usingnamespacestd;edge::edge(){cin>>left>>right;rlen=right.length();if(NODE.find(left)>NODE.length())NODE+=left;}stringedge::getlf(){returnleft;}stringedge::getrg(){returnright;}stringedge::getfirst(){returnfirst;}st
4、ringedge::getfollow(){returnfollow;}stringedge::getselect(){returnselect;}stringedge::getro(){stringstr;str+=right[0];returnstr;}intedge::getrlen(){returnright.length();}voidedge::newfirst(stringw){inti;for(i=0;ifi
5、rst.length())first+=w[i];}voidedge::newfollow(stringw){inti;for(i=0;ifollow.length()&&w[i]!='*')follow+=w[i];}voidedge::newselect(stringw){inti;for(i=0;iselect.length()&&w[i]!=
6、'*')select+=w[i];}voidedge::delfirst(){inti=first.find('*');first.erase(i,1);}/////////////////////////////////////////////////////////////////////////////////LL1.cpp#include#include#include"edge.h"usingnamespacestd;intSUM;stringNOD
7、E,ENODE;//计算firstvoidfirst(edgeni,edge*n,intx){inti,j;for(j=0;j8、llowvoidfollow(edgeni,edge*n,intx){inti,j,k,s;stringstr;for(i=0;i-1)//是非终结符if(i
8、llowvoidfollow(edgeni,edge*n,intx){inti,j,k,s;stringstr;for(i=0;i-1)//是非终结符if(i
此文档下载收益归作者所有