#include<stdio.h>
#include<string.h>
#define N 100
main()
{
int t;
int i,j;
char ch;
char x[N];
char y[N];
char a[5]={'b','e','g','i','n'};
char b[5]={'w','h','i','l','e'};
char c[4]={'t','h','e','n'};
char d[2]={'i','f'};
char e[3]={'e','n','d'};
char f[2]={'d','o'};
printf("请输入一个字符串:\n");
gets(x);
i=0;
j=0;
do
{
while(x[i]==10||x[i]==13||x[i]==9)
{
i++;
}
if(x[i]>='a'&&x[i]<='z')
{
y[j]=x[i];
j++;
}
if((t=strcmp(a,y))==0)
printf("(begin,1)");
else if((t=strcmp(b,y))==0)
printf("(while,4)");
else if((t=strcmp(c,y))==0)
printf("(then,3)");
else if((t=strcmp(d,y))==0)
printf("(if,2");
else if((t=strcmp(e,y))==0)
printf("(end,6)");
else if((t=strcmp(f,y))==0)
printf("(do,5)");
switch(x[i])
{
case '+':printf("(13,+)\n");
break;
case '-':printf("(14,-)\n");
break;
case '*':printf("(15,*)\n");
break;
case '/':printf("(16,/)\n");
break;
case ':':printf("(17,:)\n");
break;
case ':=':printf("(18,:=)\n");
break;
case '<':printf("(20,<)\n");
break;
case '<=':printf("(21,<=)\n");
break;
case '<>':printf("(22,<>)\n");
break;
case '>':printf("(23,>)\n");
break;
case '=':printf("(25,=)\n");
break;
case ';':printf("(26,;)\n");
break;
case '(':printf("(27,()\n");
break;
case ')':printf("(28,))\n");
break;
case '#':printf("(0,#)\n");
break;
}
i++;
}while(x[i]!='\0');
}