编译原理 C编写的词法分析
#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); }
用户评论