#include<stdio.h> #include<string.h> char prog[80],token[6]; char ch; int syn,p,m,n,sum,kk=0; char * rwtab[6]={"begin","if","then","while","do","end"}; main() { p=0; printf(" please intput string:"); do { ch=getchar(); prog[p++]=ch; }while(ch!='#'); p=0; scaner(); lrparser(); getch(); } /*词法扫描程序:*/ scaner() { for(n=0;n<8;n++) token[n]=NULL; m=0; ch=prog[p++]; while(ch==' ')ch=prog[p++]; if((ch<='z'&&ch>='a')||(ch<='Z'&&ch>='A')) { while((ch<='z'&&ch>='a')||(ch<='Z'&&ch>='A')||(ch<='9'&&ch>='0')) { token[m++]=ch; ch=prog[p++]; } token[m++]='