temp[0] = \0;
gettoken();
do {
if (tokentype != NAME) {
prevtoken = YES;
dcl();
} else if (typespec() == YES) {
strcat(temp, " ");
strcat(temp, token);
gettoken();
} else if (typequal() == YES) {
strcat(temp, " ");
strcat(temp, token);
gettoken();
} else
errmsg("unknown type in parameter list\n");
} while (tokentype != , && tokentype != ));
strcat(out, temp);
if (tokentype == ,)
strcat(out, ",");
}
int typespec(void)
{
static char *types[] = {"char", "int", "void"};
char *pt = token;
if (bsearch(&pt, types, sizeof(types)/sizeof(char *), sizeof(char *), compare) == NULL)
return NO;
else
return YES;
}
int typequal(void)
{
static char *typeq[] = {"const", "volatile"};
char *pt = token;
if (bsearch(&pt, typeq, sizeof(typeq)/sizeof(char *), sizeof(char *), compare) == NULL)
return NO;
else
return YES;
}
int compare(char **s, char **t)
{
return strcmp(*s, *t);
}
三.程序小结
1. 程序缺陷
当输入 int a(
输入不了了 为什么呢?