コード例 #1
0
ファイル: dcl.c プロジェクト: jefferyyuan/wypractice
void dirdcl(void) {
  int type;

  if(tokentype == '(') {
    dcl();
    if(tokentype != ')')
      errmsg("error: missing )\n");
  } else if(tokentype == NAME)
    strcpy(name, token);
  else
    prevtoken = 1;
    //printf("error: expected name or (dcl)\n");
  while((type = gettoken()) == PARENS || type == BRACKETS || type == '(')
    if(type == PARENS)
      strcat(out, " function returning");
    else if(type == '(') {
      strcat(out, " function expecting");
      parmdcl();
      strcat(out, " and returning");
    }
    else {
      strcat(out, " array");
      strcat(out, token);
      strcat(out, " of");
    }
}
コード例 #2
0
/* dirdcl: parse a direct declarator */
void dirdcl(void)
{
	int type;
	
	void parmdcl(void);
	
	if(tokentype=='('){
		dcl();
		if(tokentype!=')')
			errmsg("error:missing )\n");
	}
	else if(tokentype==NAME) /* variable name */
		strcpy(name,token);
	else
		prevtoken = YES;
		
	while((type=gettoken())==PARENS||type==BRACKETS || type == '(')
	{
		if(type==PARENS)
			strcat(out,"function returning");
		else if(type=='(')
		{
			strcat(out,"function expecting");
			parmdcl();
			strcat(out,"and returning");
		}
		else{
			strcat(out," array");
			strcat(out,token);
			strcat(out," of");
		}
	}
}
コード例 #3
0
ファイル: dirdcl.c プロジェクト: conghui/books
void dirdcl(void)
{
    int type;

    if (tokentype == '(') { /* (dcl) */
        dcl();
        if (tokentype != ')') {
            errmsg("error: missing )\n");
        }
    } else if (tokentype == NAME) { /* variable name */
        if (name[0] == '\0') {
            strncpy(name, token, MAXTOKEN);
        }
    }
    else {
        prevtoken = YES;
    }

    while ((type = gettoken()) == PARENS || type == BRACKETS ||
            type == '(') {
        if (type == PARENS) {
            strncat(out, " function returning",
                    MAXTOKEN - strlen(out) - 1);
        }
        else if (type == '(') {
            strncat(out, " function expecting", 
                    MAXTOKEN - strlen(out) - 1);
            parmdcl();
            strncat(out, " and returning", 
                    MAXTOKEN - strlen(out) - 1);
        }
        else {
            strncat(out, " array", MAXTOKEN - strlen(out) - 1);
            strncat(out, token, MAXTOKEN - strlen(out) - 1);
            strncat(out, " of", MAXTOKEN - strlen(out));
        }
    }
}