- link *type;
- Safe_calloc(type,sizeof(link));
- if (*s == ',') s++;
-
- /* is a declarator */
- if (*s == 'D') {
- s++;
- switch (*s) {
- case 'F':
- DCL_TYPE(type) = FUNCTION;
- s++;
- break;
- case 'G':
- DCL_TYPE(type) = GPOINTER;
- s++;
- break;
- case 'C':
- DCL_TYPE(type) = CPOINTER;
- s++;
- break;
- case 'X':
- DCL_TYPE(type) = FPOINTER;
- s++;
- break;
- case 'D':
- DCL_TYPE(type) = POINTER;
- s++;
- break;
- case 'I':
- DCL_TYPE(type) = IPOINTER;
- s++;
- break;
- case 'P':
- DCL_TYPE(type) = PPOINTER;
- s++;
- break;
- case 'A':
- s++;
- DCL_TYPE(type) = ARRAY ;
- DCL_ELEM(type) = strtol(s,&s,10);
- break;
- }
- } else {
- /* is a specifier */
- type->class = SPECIFIER ;
- s++;
- switch (*s) {
- case 'L':
- SPEC_NOUN(type) = V_INT;
- SPEC_LONG(type) = 1;
- s++;
- break;
- case 'I':
- SPEC_NOUN(type) = V_INT;
- s++;
- break;
- case 'S':
- case 'C':
- SPEC_NOUN(type) = V_CHAR ;
- s++;
- break;
- case 'V':
- SPEC_NOUN(type) = V_VOID;
- s++;
- break;
- case 'F':
- SPEC_NOUN(type) = V_FLOAT;
- s++;
- break;
- case 'T':
- s++;
- SPEC_NOUN(type) = V_STRUCT;
- {
- char *ss = strtok(strdup(s),",):");
-
- SPEC_STRUCT(type) = structWithName(ss);
- free(ss);
- }
- break;
- case 'X':
- s++;
- SPEC_NOUN(type) = V_SBIT;
- break;
- case 'B':
- SPEC_NOUN(type) = V_BIT;
- s++;
- SPEC_BSTR(type) = strtol(s,&s,10);
- s++;
- SPEC_BLEN(type) = strtol(s,&s,10);
- break;
- }
- while (*s != ':') s++;
- s++;
- if (*s++ == 'S')
- SPEC_USIGN(type) = 0;
- else
- SPEC_USIGN(type) = 1;
-
- }
-
- /* add the type to the symbol's type chain */
- if (sym->type)
- sym->etype = sym->etype->next = type;
- else
- sym->type = sym->etype = type;
+ link *type;
+ type = Safe_calloc(1,sizeof(link));
+ if (*s == ',') s++;
+
+ /* is a declarator */
+ if (*s == 'D') {
+ s++;
+ switch (*s) {
+ case 'F':
+ DCL_TYPE(type) = FUNCTION;
+ s++;
+ break;
+ case 'G':
+ DCL_TYPE(type) = GPOINTER;
+ s++;
+ break;
+ case 'C':
+ DCL_TYPE(type) = CPOINTER;
+ s++;
+ break;
+ case 'X':
+ DCL_TYPE(type) = FPOINTER;
+ s++;
+ break;
+ case 'D':
+ DCL_TYPE(type) = POINTER;
+ s++;
+ break;
+ case 'I':
+ DCL_TYPE(type) = IPOINTER;
+ s++;
+ break;
+ case 'P':
+ DCL_TYPE(type) = PPOINTER;
+ s++;
+ break;
+ case 'A':
+ s++;
+ DCL_TYPE(type) = ARRAY ;
+ DCL_ELEM(type) = strtol(s,&s,10);
+ break;
+ }
+ } else {
+ /* is a specifier */
+ type->class = SPECIFIER ;
+ s++;
+ switch (*s) {
+ case 'L':
+ SPEC_NOUN(type) = V_INT;
+ SPEC_LONG(type) = 1;
+ s++;
+ break;
+ case 'I':
+ SPEC_NOUN(type) = V_INT;
+ s++;
+ break;
+ case 'S':
+ case 'C':
+ SPEC_NOUN(type) = V_CHAR ;
+ s++;
+ break;
+ case 'V':
+ SPEC_NOUN(type) = V_VOID;
+ s++;
+ break;
+ case 'F':
+ SPEC_NOUN(type) = V_FLOAT;
+ s++;
+ break;
+ case 'T':
+ s++;
+ SPEC_NOUN(type) = V_STRUCT;
+ {
+ char *ss = strtok(strdup(s),",):");
+
+ SPEC_STRUCT(type) = structWithName(ss);
+ free(ss);
+ }
+ break;
+ case 'X':
+ s++;
+ SPEC_NOUN(type) = V_SBIT;
+ break;
+ case 'B':
+ SPEC_NOUN(type) = V_BIT;
+ s++;
+ SPEC_BSTR(type) = strtol(s,&s,10);
+ s++;
+ SPEC_BLEN(type) = strtol(s,&s,10);
+ break;
+ }
+ while (*s != ':') s++;
+ s++;
+ if (*s++ == 'S')
+ SPEC_USIGN(type) = 0;
+ else
+ SPEC_USIGN(type) = 1;
+
+ }
+
+ /* add the type to the symbol's type chain */
+ if (sym->type)
+ sym->etype = sym->etype->next = type;
+ else
+ sym->type = sym->etype = type;