C语言词法分析器 C语言版 源代码

您所在的位置:网站首页 c语言stdlib C语言词法分析器 C语言版 源代码

C语言词法分析器 C语言版 源代码

#C语言词法分析器 C语言版 源代码| 来源: 网络整理| 查看: 265

#include stdio.h

#include string.h

#include stdlib.h

char *key0[]={" ","auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","_Complex","_Imaginary","union","unsigned","void","volatile","while"};

/*保留字表*/

char *key1[]={" ","(",")","[","]","{","}",",",";","'"};

/*分隔符表*/

char *key2[]={" ","+","-","*","/","%","","","==","=","=","!=","!","&&","||","","","~","|","^","&","=","?:","-","++","--",".","+=","-=","*=","/="};

/*运算符表*/

int xx0[35],xx1[10],xx2[31];

int temp_key3=0,temp_c40=0,temp_c41=0,temp_c42=0,temp_c43=0;

/******* 初始化函数 *******/

void load()

{

int mm;

for (mm=0;mm=34;mm++)

{

xx0[mm]=0;

}

for (mm=0;mm=9;mm++)

{

xx1[mm]=0;

}

for (mm=0;mm=30;mm++)

{

xx2[mm]=0;

}

FILE *floading;

if ((floading=fopen("key0.txt","w"))==NULL)

{

printf("Error! Can't create file : key0.txt");

return;

}

fclose (floading);

/*建立保留字表文件:key0.txt*/

if ((floading=fopen("key1.txt","w"))==NULL)

{

printf("Error! Can't create file : key1.txt");

return;

}

/*建立分隔符表文件:key1.txt*/

if ((floading=fopen("key2.txt","w"))==NULL)

{

printf("Error! Can't create file : key2.txt");

return;

}

fclose(floading);

/*建立运算符表文件:key2.txt*/

if ((floading=fopen("key3.txt","w"))==NULL)

{

printf("Error! Can't create file : key3.txt");

return;

}

fclose (floading);

/*建立标识符表文件:key3.txt*/

if ((floading=fopen("c40.txt","w"))==NULL)

{

printf("Error! Can't create file : c40.txt");

return;

}

fclose (floading);

/*建立整数类型常量表文件:c40.txt*/

if ((floading=fopen("c41.txt","w"))==NULL)

{

printf("Error! Can't create file : c41.txt");

return;

}

fclose (floading);

/*建立浮点类型常量表文件:c41.txt*/

if ((floading=fopen("c42.txt","w"))==NULL)

{

printf("Error! Can't create file : c42.txt");

return;

}

fclose (floading);

/*建立字符类型常量表文件:c42.txt*/

if ((floading=fopen("c43.txt","w"))==NULL)

{

printf("Error! Can't create file : c43.txt");

return;

}

fclose (floading);

/*建立字符串类型常量表文件:c43.txt*/

if ((floading=fopen("defination.txt","w"))==NULL)

{

printf("Error! Can't create file : defination.txt");

return;

}

fclose (floading);

/*建立注释文件:defination.txt*/

if ((floading=fopen("output.txt","w"))==NULL)

{

printf("Error! Can't create file : output.txt");

return;

}

fclose (floading);

/*建立内部码文件:output.txt*/

if ((floading=fopen("temp_key1","w"))==NULL)

{

printf("Error! Can't create file : temp_key1");

return;

}

fclose (floading);

/*建立保留字临时表文件:temp_key1*/

if ((floading=fopen("temp_key3","w"))==NULL)

{



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3