LL(1)文法的预测分析
2008-12-05 22:27
//
#ifndef HEAD_EDGE
#define HEAD_EDGE
#include<string>
using namespace std;
extern int SUM;
extern string NODE,ENODE;
class edge
{
public:
edge();
string getlf();
string getrg();
string getfirst();
string getfollow();
string getselect();
string getro();
int getrlen();
void newfirst(string w);
void newfollow(string w);
void newselect(string w);
void delfirst();
private:
string left,right,first,follow,select;
int rlen;
};
#endif
/////////////////////////////////////////////////////////////////////////////
//
#include<iostream>
#include ""
using namespace std;
edge::edge()
{
cin>>left>>right;
rlen=();
if((left)>())
NODE+=left;
}
string edge::getlf()
{
return left;
}
string edge::getrg()
{
return right;
}
string edge::getfirst()
{
return first;
}
string edge::getfollow()
{
return follow;
}
string edge::getselect()
{
return select;
}
string edge::getro()
{
string str;
str+=right[0];
return str;
}
int edge::getrlen()
{
return ();
}
void edge::newfirst(string w)
{
int i;
for(i=0;i<();i++)
if((w[i])>())
first+=w[i];
}
void edge::newfollow(string w)
{
int i;
for(i=0;i<();i++)
if((w[i])>()&&w[i]!='*')
follow+=w[i];
}
void edge::newselect(string w)
{
int i;
for(i=0;i<();i++)
if((w[i])>()&&w[i]!='*')
select+=w[i];
}
void edge::delfirst()
{
int i=('*');
(i,1);
}
///////////////////////////////////////////////////////////////////////////////
//
#include<iostream>
#include<string>
#include ""
using namespace std;
int SUM;
string NODE,ENODE;
//计算first
void first(edge ni,edge *n,int x)
{
int i,j;
for(j=0;j<SUM;j++)
{
if(()==n[j].getlf())
{
if((n[j].getro())<())
{
for(i=0;i<SUM;i++)
if(n[i].getlf()==n[j].getr
ll(1)文法的预测分析 来自淘豆网www.taodocs.com转载请标明出处.