资源简介

东北大学编译原理课程设计,采用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

评论

共有 条评论