/** 声明符 <declarator>::={<TK_STAR>}[<function_calling_convention>] [<struct_member_alignment>]<direct_declarator> */ void declarator(){ int fc; while(TK_STAR == token) get_token(); function_calling_convention(&fc); struct_member_alignment(); direct_declarator(); }
struct typetree *declarator(struct typetree *base, const char **symbol) { while (peek().token == '*') { base = pointer(base); } return direct_declarator(base, symbol); }
TOKEN declarator(SYMBOL s) { TOKEN ptr = NULL; TOKEN direct_dec = NULL; ptr = pointer(); direct_dec = direct_declarator(s); return direct_dec; }
int declarator(char* result) { char tmp[MAXTOKEN] = ""; char token[MAXTOKEN]; for (int type = gettoken(token); type == '*'; type = gettoken(token)) { type = gettoken(token); if (type == CONST) { strcat(tmp, " const pointer to"); } else { strcat(tmp, " pointer to"); unget_token(); } } unget_token(); int ret = direct_declarator(result); strcat(result, tmp); return ret; }
int direct_declarator(void) { if( lookaheadT.type == ID ) { match(ID); } else if( lookaheadT.type == LPAREN ) { match(LPAREN); declarator(); match(RPAREN); } else if( direct_declarator() ) { if( lookaheadT.type == LBRACKET ) { match(LBRACKET); if( constant_expression() ) { } match(RBRACKET); } else if( lookaheadT.type == LPAREN ) { match(LPAREN); if( parameter_type_list() ) { } else if ( identifier_list() ) { } match(RPAREN); } } }
int declarator(void) { if( pointer() ) { } direct_declarator(); }