+typedef struct declarator_part declarator_part;
+struct declarator_part {
+ int pointers;
+ method_type_t *method_type;
+ declarator_part *inner;
+};
+
+static struct obstack temp_obst;
+
+static
+declarator_part *parse_inner_declarator(declaration_t *declaration)
+{
+ declarator_part *part = obstack_alloc(&temp_obst, sizeof(part[0]));
+ memset(part, 0, sizeof(part[0]));
+
+ part->pointers = parse_pointers();
+
+ switch(token.type) {
+ case T_IDENTIFIER:
+ declaration->symbol = token.v.symbol;
+ declaration->source_position = token.source_position;
+ next_token();
+ break;
+ case '(':
+ next_token();
+ part->inner = parse_inner_declarator(declaration);
+ expect(')');
+ break;
+ default:
+ parse_error_expected("problem while parsing declarator", T_IDENTIFIER,
+ '(', 0);
+ }
+
+ while(1) {
+ switch(token.type) {
+ case '(':
+ next_token();
+
+#if 0
+ int top = environment_top();
+ context_t *last_context = context;
+ set_context(&declaration->context);
+#endif
+
+ method_type_t *method_type
+ = allocate_type_zero(sizeof(method_type[0]));
+ method_type->type.type = TYPE_METHOD;
+
+ parse_parameters(method_type);
+
+#if 0
+ assert(context == &declaration->context);
+ set_context(last_context);
+ environment_pop_to(top);
+#endif
+
+ part->method_type = method_type;
+
+ expect(')');
+ break;
+ case '[':
+ next_token();
+
+ if(token.type == T_static) {
+ next_token();
+ }
+
+ unsigned type_qualifiers = parse_type_qualifiers();
+ if(type_qualifiers != 0) {
+ if(token.type == T_static) {
+ next_token();
+ }
+ }
+
+ /* TODO */
+
+ if(token.type == '*' && la(1)->type == ']') {
+ next_token();
+ } else if(token.type != ']') {
+ parse_assignment_expression();
+ }
+
+ expect(']');
+ break;
+ default:
+ goto declarator_finished;
+ }
+ }
+
+declarator_finished:
+ parse_attributes();
+
+ return part;
+}
+
+static
+type_t *construct_declarator_type(declarator_part *part, type_t *type)
+{
+ do {
+ type = make_pointers(type, part->pointers);
+
+ method_type_t *method_type = part->method_type;
+ if(method_type != NULL) {
+ method_type->result_type = type;
+
+ type = (type_t*) method_type;
+ }
+
+ part = part->inner;
+ } while(part != NULL);
+
+ return type;
+}
+
+static
+void parse_declarator(declaration_t *declaration, storage_class_t storage_class,
+ type_t *type, int may_omit_identifier)
+{
+ (void) may_omit_identifier;
+ declarator_part *part = parse_inner_declarator(declaration);
+
+ declaration->type = construct_declarator_type(part, type);
+ declaration->storage_class = storage_class;
+ obstack_free(&temp_obst, part);
+}
+
+#if 0