1. 首页
  2. 编程语言
  3. C
  4. 编译原理 C编写的词法分析

编译原理 C编写的词法分析

上传者: 2021-05-04 10:06:50上传 TXT文件 1.9KB 热度 17次
#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); }
用户评论