while (!myfile.eof())
{
myfile.getline(buffer[n],10);
n++;
}
myfile.close();
return n;
}
void Compile::Scan(int n,char buffer[][10],double * type)
{
int i,j;
for(i=0;i')
{
int a,big1=0,small1=0,big2=0,small2=0;
for(a=0;a=65&&buffer[i][a]<=90)
big1++;
else
if(buffer[i][a]>=97&&buffer[i][a]<=122||buffer[i][a]>=48&&buffer[i][a]
<=57)
small1++;
else continue;
}
for(a=j+2;a<10;a++)
{
if(buffer[i][a]>=65&&buffer[i][a]<=90)
big2++;
else
if(buffer[i][a]>=97&&buffer[i][a]<=122||buffer[i][a]>=48&&buffer[i][a]
<=57||buffer[i][a]==35)
small2++;
else continue;
}
if(big1==1&&small1==0&&((big2==0||big2==1)&&small2==1))
{
if(buffer[i][4]=='\0')
type[i]=3;
else
if(buffer[i][3]>=65&&buffer[i][3]<=90)
type[i]=2.5;
else
type[i]=2.8;
}
else if(big1==1&&small1==0&&!(big2<0&&small2<0))
type[i]=2;
else if(big1>=1&&(big1+small1)<=(big2+small2))
type[i]=1;
else if(big1>=1&&small1>=0&&!(big2<0&&small2<0))
type[i]=0;
else
type[i]=-1;
}
else continue;
}
}
void Compile::Sort(int n ,double * type)
{
int i,j;
int swap=0;
for(i=0;i
type[j+1])
{
swap=type[j];
type[j]=type[j+1];
type[j+1]=swap;
}
else continue;
}
if(type[0]>2&&type[0]!=3)
for(i=0;i{
case 0:
cout<<"此文法为 0 型文法"<
实验结果: