词法分析


#include <stdio.h> #include <string.h> char *syst[6]={"begin","if","then","while","do","end"}; main() { int syn,sum; p=0; printf("\n 请输入一个字符串(用$结束):\n"); do{ scanf("%c",&ch); prog[p++]=ch; }while(ch!='$'); p=0; do{ scaner(); switch(syn) { case 11: printf("( %-10d%5d )\n",sum,syn); break; case -1: printf("you have input a wrong string\n"); //getch(); return 0; break; default: printf("( %-10s%5d )\n",token,syn); break; } }while(syn!=0); //getch(); }

 

posted @ 2016-10-08 12:59  126刘畅  阅读(94)  评论(0编辑  收藏  举报