【文件属性】:
文件名称:编译原理 C编写的词法分析
文件大小:2KB
文件格式:TXT
更新时间:2012-12-11 07:18:03
词法分析
#include
#include
#include
char prog[80];
char token[8];
char ch;
int syn=0,p,m,n,sum=0,i=0,j=0;
char *rwtab[6]={"begin","if","then","while","do","end"};
main()
{p=0;
printf("\n please input string: \n");
do{ch=getchar();
prog[p++]=ch;
}
while(ch!='#');
p=0;
do{scaner();
switch(syn)
{case 11:printf("(%d,%d)",sum,syn);
case -1:printf("error");
default:printf("(%s,%d)",token,syn);
}
}while(syn!=0);
}