?? cpp2.cpp
字號:
L[i]=c;
i=i+1;
break;
}
case 4:
state=fail();
break;
case 5:
c=nextchar();
if(c=='-')
{L[i]=c;
i=i+1;
state=6;
break;
}
else
if(isdigit(c))
{L[i]=c;
i=i+1;
state=7;
break;
}
else
{state=fail();
e=e-1;
break;
}
case 6:
c=nextchar();
if(isdigit(c))
{L[i]=c;
i=i+1;
state=7;
break;
}
else
if(c=='#')
{L[i]='\0';
printf("%s 符號\n",L);
int t;
for(t=0;t<10;t++)
two[v].name[t]=L[t];
two[v].address=1;
v=v+1;
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
printf("%s 符號\n",L);
int n;
for(n=0;n<10;n++)
two[v].name[n]=L[n];
two[v].address=1;
v=v+1;
i=0;
state=14;
break;
}
else
{L[i]=c;
i=i+i;
state=13;
break;
}
case 7:
c=nextchar();
if(c=='.')
{L[i]=c;
i=i+1;
state=8;
break;
}
else
if(isdigit(c))
{L[i]=c;
i=i+1;
state=7;
break;
}
else
if(c=='#')
{L[i]='\0';
digit(L);//拼數,打印,存表(兩張表)
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
digit(L);
i=0;
state=14;
break;
}
else
if(c=='e')
{L[i]=c;
i=i+1;
state=10;
break;
}
else
{L[i]=c;
i=i+1;
state=13;
break;
}
case 8:
c=nextchar();
if(isdigit(c))
{L[i]=c;
i=i+1;
state=9;
break;
}
else
if(c=='#')
{L[i]='\0';
printf("%s 錯誤\n",L);
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
printf("%s 錯誤\n",L);
i=0;
state=14;
break;
}
else
{L[i]=c;
i=i+1;
state=13;
break;
}
case 9:
c=nextchar();
if(c=='e')
{L[i]=c;
i=i+1;
state=10;
break;
}
else
if(isdigit(c))
{L[i]=c;
i=i+1;
state=9;
break;
}
else
if(c=='#')
{L[i]='\0';
digit(L);
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
digit(L);
i=0;
state=14;
break;
}
else
{L[i]=c;
i=i+1;
state=13;
break;
}
case 10:
c=nextchar();
if(c=='-')
{L[i]=c;
i=i+1;
state=11;
break;
}
else
if(isdigit(c))
{L[i]=c;
i=i+1;
state=12;
break;
}
else
if(c=='#')
{L[i]='\0';
printf("%s 錯誤\n",L);
j=i;
break;
}
else
if(c==' ')
{L[i]='\0';
printf("%s 錯誤\n",L);
i=0;
state=14;
break;
}
else
{L[i]=c;
i=i+1;
state=13;
break;
}
case 11:
c=nextchar();
if(isdigit(c))
{L[i]=c;
i=i+1;
state=12;
break;
}
else
if(c=='#')
{L[i]='\0';
printf("%s 錯誤\n",L);
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
printf("%s 錯誤\n",L);
i=0;
state=14;
break;
}
else
{L[i]=c;
i=i+1;
state=13;
break;
}
case 12:
c=nextchar();
if(isdigit(c))
{L[i]=c;
i=i+1;
state=12;
break;
}
else
if(c=='#')
{L[i]='\0';
digit(L);
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
digit(L);
i=0;
state=14;
break;
}
else
{L[i]=c;
i=i+1;
state=13;
break;
}
case 13:
c=nextchar();
if(c=='#')
{L[i]='\0';
printf("%s 錯誤\n",L);
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
printf("%s 錯誤\n",L);
i=0;
state=14;
break;
}
else
{L[i]=c;
i=i+1;
state=13;
break;
}
case 14:
state=fail();
break;
case 15:
c=nextchar();
if(p=isyunsuanfu1(c))//判斷是否為單運算符
{L[i]=c;
i=i+1;
state=16;
break;
}
else
{state=fail();
e=e-1;
break;
}
case 16:
c=nextchar();
if(isyunsuanfu1(c))
{L[i]=c;
i=i+1;
state=17;
break;
}
else
if(c=='#')
{L[i]='\0';
yunsuanfu(L,p);//輸出運算符并存表
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
yunsuanfu(L,p);
i=0;
state=19;
break;
}
else
{L[i]=c;
i=i+1;
state=18;
break;
}
case 17:
c=nextchar();
if(c=='#')
{L[i]='\0';
if(q=isyunsuanfu2(L))//判斷是否為復合運算符
yunsuanfu(L,q);
else
printf("%s 錯誤\n",L);
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
if(q=isyunsuanfu2(L))//判斷是否為復合運算符
yunsuanfu(L,q);
else
printf("%s 錯誤\n",L);
i=0;
state=19;
break;
}
else
{L[i]=c;
i=i+1;
state=18;
break;
}
case 18:
c=nextchar();
if(c=='#')
{L[i]='\0';
printf("%s 錯誤\n",L);
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
printf("%s 錯誤\n",L);
i=0;
state=19;
break;
}
else
{L[i]=c;
i=i+1;
state=18;
break;
}
case 19:
state=fail();
break;
case 20:
c=nextchar();
if(h=isjiefu(c))//判斷是否為界符
{L[i]=c;
i=i+1;
state=21;
break;
}
else
{L[i]=c;
i=i+1;
state=22;
break;
}
case 21:
c=nextchar();
if(c=='#')
{L[i]='\0';
jiefu(L,h);//輸出界符并保存
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
jiefu(L,h);
i=0;
state=23;
break;
}
else
{L[i]=c;
i=i+1;
state=22;
break;
}
case 22:
c=nextchar();
if(c=='#')
{L[i]='\0';
printf("%s 錯誤\n",L);
j=1;
break;
}
else
if(c==' ')
{L[i]='\0';
printf("%s 錯誤\n",L);
i=0;
state=23;
break;
}
else
{L[i]=c;
i=i+1;
state=22;
break;
}
case 23:
state=fail();
break;
}
if(j==1)
break;
}
}
void main()
{printf("輸入文件名:");
char L[15];
scanf("%s",L);
printf("*******************************************************************************\n");
FILE *fp;
if((fp=fopen(L,"rb"))==NULL)
{printf("\n%s 文件無法打開",L);
return;
}
char c='$';
int i=0;
while((c!='#')&&(i<200))
{
if(fread(&c,sizeof(c),1,fp)!=1)
{printf("\n%s 文件讀入錯誤",L);
break;
}
if((c==13)||(c==10))
c=' ';
A[i]=c;
i=i+1;
}
fclose(fp);
printf("原代碼:\n");
printf("%s\n",A);
printf("******************************************************************************\n");
printf("分析結果:\n");
nexttaken();
printf("*******************************************************************************");
printf("標識符表:\n");
int x;
for(x=1;x<r;x++)
printf("%s\n",C[x]);
printf("*******************************************************************************\n");
printf("常數表:\n");
int z;
for(z=1;z<u;z++)
printf("%f\n",D[z]);
printf("*******************************************************************************\n");
printf("二元組:\n");
int y;
for(y=0;y<v;y++)
printf("%s %d\n",two[y].name,two[y].address);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -