static void param_declarator(node_t ** ty, struct token **id) { if (token->id == '*') { node_t *pty = ptr_decl(); prepend_type(ty, pty); } if (token->id == '(') { if (first_decl(lookahead())) { abstract_declarator(ty); } else { node_t *type1 = *ty; node_t *rtype = NULL; expect('('); param_declarator(&rtype, id); expect(')'); if (token->id == '(' || token->id == '[') { node_t *faty; cc_assert(id); if (*id) { faty = func_or_array(false, NULL); } else { faty = func_or_array(true, NULL); } attach_type(&faty, type1); attach_type(&rtype, faty); } *ty = rtype; } } else if (token->id == '[') { abstract_declarator(ty); } else if (token->id == ID) { declarator(ty, id, NULL); } }
static void abstract_declarator(node_t ** ty) { cc_assert(ty); if (token->id == '*' || token->id == '(' || token->id == '[') { if (token->id == '*') { node_t *pty = ptr_decl(); prepend_type(ty, pty); } if (token->id == '(') { if (first_decl(lookahead())) { node_t *faty = func_or_array(true, NULL); prepend_type(ty, faty); } else { expect('('); abstract_declarator(ty); expect(')'); } } else if (token->id == '[') { node_t *faty = func_or_array(true, NULL); prepend_type(ty, faty); } } else { error("expect '(' or '[' at '%s'", token->name); } }
int direct_abstract_declarator(void) { if( lookaheadT.type == LPAREN ) { match(LPAREN); if( abstract_declarator() ) { } else if( parameter_type_list() ) { } match(RPAREN); } else if ( lookaheadT.type == LBRACKET ) { match(LBRACKET); if( constant_expression() ) {} match(RBRACKET); } else if( direct_abstract_declarator() ) { match(LBRACKET); if( constant_expression() ) {} match(RBRACKET); } else if( direct_abstract_declarator() ) { match(LPAREN); if( parameter_type_list() ) {} match(RPAREN); } else { abort(); } }
int type_name(void) { specifier_qualifier_list(); if( abstract_declarator() ) { } }
int parameter_declaration(void) { declaration_specifiers(); if( declarator() ) { } else if( abstract_declarator() ) { } }