TAG_SYMBOL * defstruct (char *sname, int storage, int is_struct) { int itag ; /* index of tag in tag symbol table */ char nam[20]; /* Dummy name */ TAG_SYMBOL *tag = NULL; if ( tagptr >= ENDTAG ) { error(E_STROV) ; } if ( sname && sname[0] == 0 ) sname = NULL; if ( sname && (tag = findtag(sname) ) ) { if ( tag->weak == 0 ) { if ( rcmatch('{') ) multidef(); else return tag; } itag = tag - tagtab; } /* No tag defined for this, so leave it alone */ if ( tag == NULL ) { tag = tagptr++; itag = tag - tagtab ; sprintf(nam,"0st%d",itag); if ( sname == NULL ) sname = nam; strcpy(tag->name,sname); tag->size = 0; tag->ptr = tag->end = membptr ; /* Set so no member searches done.. */ dummy_sym[NTYPE+1+itag] = addglb(nam,POINTER,STRUCT,0,STATIK,0,itag) ; tag->weak = 1; } if ( rcmatch('{' ) ) { /* increment tagptr to add tag to table */ tag->ptr = membptr; tag->weak = 0; needchar('{') ; while ( dodeclare(storage, tag, is_struct) ) ; needchar('}') ; tag->end = membptr ; } return tag ; }
void parse() { while ( eof == 0 ) { /* do until no more input */ if ( amatch("extern") ) dodeclare(EXTERNAL, NULL_TAG, 0) ; else if (amatch("static")) dodeclare(LSTATIC, NULL_TAG, 0) ; else if (amatch("typedef")) dodeclare(TYPDEF,NULL_TAG,0) ; else if (dodeclare(STATIK, NULL_TAG, 0) ) ; else if ( ch() == '#' ) { if (match("#asm")) doasm(); else if (match("#include")) doinclude() ; else if (match("#define") ) addmac() ; else { clear(); blanks(); } } else newfunc(); blanks(); /* force eof if pending */ } }