資源簡介
東北大學編譯原理課程設計,采用C語言,數據結構主要是鏈表和指針數組,有完善的token,函數表,四元式,單寄存器后端(無優化)。

代碼片段和文件信息
#include?“list.h“
struct?character?chara;
struct?str?strin;
struct?constant?cons;
struct?identifier?identi;
struct?Token?token;
struct?cengci?myceng;
struct?func_all?myallfunc;
siyuanshi?si1;
SEM?mysem1;
backend?bkd;
struct?Token*?temp_p?=?&token;
struct?cengci*?myceng_temp?=?&myceng;
struct?func_all*?allfunc?=?&myallfunc;
char?shuju_type[4][8]?=?{?“void““int““float““char“?};
char?type[2][10]?=?{?“變量““函數“?};
int?line[100];
int?scan_flag?=?0;
int?line_number?=?0;
int?token_flag?=?1;
int?h=1abcd=0;
extern?ifnum[5];
extern?wnum[5];
extern?elsenum[5];
extern?wend[5];
int?main()
{
initcharac(&chara);
initstr(&strin);
initconstant(&cons);
initiden(&identi);
inittoken(&token);
init_siyuanshi(&si1);
init_SEM(&mysem1);
init_cengci(&myceng);
initallfunc(&myallfunc);
FILE*?fp;
char?ch;
fp?=?fopen(“test.txt“?“r“);
while?((ch?=?getc(fp))?!=?EOF)
{
if?(ch?==?‘?‘?||?ch?==?‘\t‘?||?ch?==?‘\n‘)
{
if?(ch?==?‘\n‘)
{
line[line_number]?=?scan_flag;
line_number++;
}
}
else
{
fseek(fp?-1L?SEEK_CUR);
if?(!scan(fp?&chara?&strin?&cons?&identi?&token))
break;
else
scan_flag++;
}
}
int?temp;
char?c_temp?=?‘(‘;
struct?character*?temp4;
struct?str*?temp5;
struct?constant*?temp3;
struct?identifier*?temp1;
struct?Token*?temp2?*?token_fuhao?*?token_hanshu;
temp1?=?&identi;
token_hanshu?=?token_fuhao?=?temp2?=?&token;
temp3?=?&cons;
temp4?=?&chara;
temp5?=?&strin;
temp?=?1;
printf(“*************************************************************************************\n“);
printf(“character:\n“);
if?(temp4->cha?==?NULL)
printf(“NO?DATE!\n“);
else
{
printf(“%d\t%s\n“?temp?temp4->cha);
while?(temp4->next?!=?NULL)
{
temp4?=?temp4->next;
temp++;
printf(“%d\t%s\n“?temp?temp4->cha);
}
}
temp?=?1;
printf(“*************************************************************************************\n“);
printf(“string:\n“);
if?(temp5->st?==?NULL)
printf(“NO?DATE!\n“);
else
{
printf(“%d\t%s\n“?temp?temp5->st);
while?(temp5->next?!=?NULL)
{
temp5?=?temp5->next;
temp++;
printf(“%d\t%s\n“?temp?temp5->st);
}
}
temp?=?1;
printf(“*************************************************************************************\n“);
printf(“constant:\n“);
if?(temp3->con?0)
printf(“NO?DATE!\n“);
else
{
printf(“%d\t%f\n“?temp?temp3->con);
while?(temp3->next?!=?NULL)
{
temp3?=?temp3->next;
temp++;
printf(“%d\t%f\n“?temp?temp3->con);
}
}
printf(“*************************************************************************************\n“);
temp?=?1;
printf(“identifier:\n“);
if?(temp1->iden?==?NULL)
printf(“NO?DATE!\n“);
else
{
printf(“%d\t%s\n“?temp?temp1->iden);
while?(temp1->next?!=?NULL)
{
temp1?=?temp1->next;
temp++;
printf(“%d\t%s\n“?temp?temp1->iden);
}
}
printf(“*
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-12-22?14:27??編譯課設\
?????文件????????1237??2019-12-19?16:14??編譯課設\asfas.cbp
?????文件?????????975??2019-12-20?21:03??編譯課設\asfas.depend
?????文件?????????905??2019-12-22?14:27??編譯課設\asfas.layout
?????目錄???????????0??2019-12-20?17:52??編譯課設\bin\
?????目錄???????????0??2019-12-20?17:52??編譯課設\bin\Debug\
?????文件???????74320??2019-12-19?20:14??編譯課設\bin\Debug\asfas.exe
?????文件????????4651??2019-12-19?17:10??編譯課設\list.h
?????文件????????8490??2019-12-19?15:54??編譯課設\main.c
?????目錄???????????0??2019-12-20?17:52??編譯課設\obj\
?????目錄???????????0??2019-12-20?17:52??編譯課設\obj\Debug\
?????文件???????12820??2019-12-19?17:13??編譯課設\obj\Debug\main.o
?????文件???????39125??2019-12-19?17:13??編譯課設\obj\Debug\parser.o
?????文件???????12867??2019-12-19?20:14??編譯課設\obj\Debug\token.o
?????文件???????41223??2019-12-19?17:08??編譯課設\parser.c
?????文件?????????153??2019-12-19?20:38??編譯課設\test.txt
?????文件???????10906??2019-12-19?20:14??編譯課設\token.c
- 上一篇:這是用C語言實現模糊控制的算法程序
- 下一篇:數據結構列車時刻表管理系統
評論
共有 條評論