資源簡介
運用所學知識,編程實現符號表管理程序。讀出源程序中與C語言詞法規定相一致的標識符,并在符號表中進行查找,若存在則輸出該標識符及其編號和位置;否則將其填入符號表,并分配編號,確定位置,輸出該標識符。輸出標識符表
代碼片段和文件信息
#include?
#include?
#include?
int?main()
{
????char?num[100][20]={“a““b““c“};
int?length=3;
char?ch[2]=““;
FILE?*fp;
if(!(fp=fopen(“r.txt““r“)))
{?
printf(“cannot?open?the?file!“);
return?0;
}
char?a[20]=““;
????FILE?*fpt;
????fpt?=?fopen(“w.txt““w“);
????while((ch[0]=fgetc(fp))!=EOF)
{
if(strlen(a)==0)
{
if((ch[0]>=‘a‘&&ch[0]<=‘z‘)||(ch[0]>=‘A‘&&ch[0]<=‘Z‘))
{
strcat(ach);
????continue;
}
else
continue;
}
if((ch[0]>=‘a‘&&ch[0]<=‘z‘)||(ch[0]>=‘A‘&&ch[0]<=‘Z‘)||(ch[0]>=‘0‘&&ch[0]<=‘9‘))
strcat(ach);
else
{
int?i=0;
for(i=0;i
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????1480??2020-04-19?16:20??編譯原理實驗查填符號表.cpp
評論
共有 條評論