char ch;
int syn,p,m,n,sum,kk;
char * rwtab[6]={\,\,\,\,\,\}; ////////////////////////////////////////////////////////// /*词法扫描程序:*/ void scaner() {
for(m=0;m
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++]='\\0'; ch=prog[--p]; syn=10;
for(n=0;n<6;n++)
if(strcmp(token,rwtab[n])==0) {
syn=n+1; //给出syn值 break; } } else
if((ch<='9'&&ch>='0')) { sum=0;
while((ch<='9'&&ch>='0'))
{
sum=sum*10+ch-'0'; ch=prog[p++]; }
ch=prog[--p]; syn=11; }
else switch(ch) {
case '<':m=0;token[m++]=ch; ch=prog[p++]; if(ch=='>') { syn=21; token[m++]=ch; } else
if(ch=='=') { syn=22; token[m++]=ch; } else { syn=20; ch=prog[--p]; } break;
case '>':token[m++]=ch; ch=prog[p++]; if(ch=='=') { syn=24; token[m++]=ch; } else { syn=23; ch=prog[--p];
} break;
case ':':token[m++]=ch; ch=prog[p++]; if(ch=='=') { syn=18; token[m++]=ch;
} else
{
syn=17; ch=prog[--p]; } break;
case '+':syn=13;token[0]=ch;break; case '-':syn=14;token[0]=ch;break; case '*':syn=15;token[0]=ch;break; case '/':syn=16;token[0]=ch;break; case ':=':syn=18;token[0]=ch;break; case '<>':syn=21;token[0]=ch;break; case '<=':syn=22;token[0]=ch;break; case '>=':syn=24;token[0]=ch;break; case '=':syn=25;token[0]=ch;break; case ';':syn=26;token[0]=ch;break; case '(':syn=27;token[0]=ch;break; case ')':syn=28;token[0]=ch;break; case '#':syn=0;token[0]=ch;break; default:syn=-1;
break;
} }
/////////////////////////////////////////////////////// void statement() {
if (syn==10) {
scaner(); //读下一个单词符号 if (syn==18) {
scaner(); //读下一个单词符号
expression(); //调用expression函数 } else {
printf(\); kk=1; } } else
{
printf(\); kk=1; } return; }
//////////////////////////////////////////////////////// void expression() { term();
while(syn==13 || syn==14) {
scaner(); term(); } return; }
/////////////////////////////////////////////////////// void term() { factor();
while(syn==15 || syn==16) {
scaner(); factor(); } return; }
////////////////////////////////////////////////////// void lrparser() {
if (syn==1) //begin {
scaner();
yucu();
if (syn==6) //end {
scaner();
if (syn==0 && kk==0) printf(\); } else {