编译原理实验报告 词法分析(3)
发布时间:2021-06-06
发布时间:2021-06-06
int syn,p,q,m=0,n,sum=0;
char *rwtab[5]={"else","if","then","while","do"};
char *operat[9]={"+","-","*","/",">","<",">=","<=","="};
int scaner() { for(n=0;n<8;n++) token[n]=NULL; ch=prog[p++]; if((ch>='A'&&ch<='Z')||( ch>='a'&&ch<='z')) { m=0; while((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')) {token[m++]=ch; ch=prog[p++]; for(n=0;n<5;n++) if(strcmp(token,rwtab[n])==0) { syn=1; token[m++]='\0'; p--; return 0; } } token[m++]='\0'; p--; syn=2; return 0; } if((ch=='+')||(ch=='-')||(ch=='*')||(ch=='/')||(ch=='=')||(ch=='>=')||(ch=='<=')||ch=='<'||ch=='>') { syn=4; token[0]=ch; token[1]='\0'; return 0; }
else if(ch>='0'&&ch<='9') { sum=0; while(ch>='0' && ch<='9') { sum=sum*10+ch-'0';
上一篇:魔法城堡主持词
下一篇:浅析苏宁发展现状及营销策略