|
|
1.1 ! root 1: /* ! 2: * C compiler. ! 3: * Symbol table initialization. ! 4: */ ! 5: #ifdef vax ! 6: #include "INC$LIB:cc0.h" ! 7: #else ! 8: #include "cc0.h" ! 9: #endif ! 10: ! 11: /* ! 12: * Initialized tokens. ! 13: * Each of these gets linked in place ! 14: * into the hash table. ! 15: */ ! 16: static TOK txfile={0,0}; static char cxfile[]="__FILE__"; ! 17: static TOK txuline={0,0}; static char cxuline[]="__LINE__"; ! 18: static TOK txdate={0,0}; static char cxdate[]="__DATE__"; ! 19: static TOK txtime={0,0}; static char cxtime[]="__TIME__"; ! 20: static TOK txstdc={0,0}; static char cxstdc[]="__STDC__"; ! 21: static TOK txudefined={0,0}; static char cxudefined[]="defined"; ! 22: static TOK txdefine={0,0}; static char cxdefine[]="#define"; ! 23: static TOK txinclude={0,0}; static char cxinclude[]="#include"; ! 24: static TOK txundef={0,0}; static char cxundef[]="#undef"; ! 25: static TOK txline={0,0}; static char cxline[]="#line"; ! 26: static TOK txassert={0,0}; static char cxassert[]="#assert"; ! 27: static TOK txerror={0,0}; static char cxerror[]="#error"; ! 28: static TOK txif={0,0}; static char cxif[]="#if"; ! 29: static TOK txifdef={0,0}; static char cxifdef[]="#ifdef"; ! 30: static TOK txifndef={0,0}; static char cxifndef[]="#ifndef"; ! 31: static TOK txelse={0,0}; static char cxelse[]="#else"; ! 32: static TOK txelif={0,0}; static char cxelif[]="#elif"; ! 33: static TOK txendif={0,0}; static char cxendif[]="#endif"; ! 34: static TOK tint={0,0}; static char cint[]="int"; ! 35: static TOK tchar={0,0}; static char cchar[]="char"; ! 36: static TOK tfloat={0,0}; static char cfloat[]="float"; ! 37: static TOK tdouble={0,0}; static char cdouble[]="double"; ! 38: static TOK tunsigned={0,0}; static char cunsigned[]="unsigned"; ! 39: static TOK tsigned={0,0}; static char csigned[]="signed"; ! 40: static TOK tregister={0,0}; static char cregister[]="register"; ! 41: static TOK tlong={0,0}; static char clong[]="long"; ! 42: static TOK tstruct={0,0}; static char cstruct[]="struct"; ! 43: static TOK tunion={0,0}; static char cunion[]="union"; ! 44: static TOK tenum={0,0}; static char cenum[]="enum"; ! 45: static TOK tauto={0,0}; static char cauto[]="auto"; ! 46: static TOK tvoid={0,0}; static char cvoid[]="void"; ! 47: static TOK tstatic={0,0}; static char cstatic[]="static"; ! 48: static TOK textern={0,0}; static char cextern[]="extern"; ! 49: static TOK tgoto={0,0}; static char cgoto[]="goto"; ! 50: static TOK treturn={0,0}; static char creturn[]="return"; ! 51: static TOK tif={0,0}; static char cif[]="if"; ! 52: static TOK twhile={0,0}; static char cwhile[]="while"; ! 53: static TOK tfor={0,0}; static char cfor[]="for"; ! 54: static TOK tdo={0,0}; static char cdo[]="do"; ! 55: static TOK telse={0,0}; static char celse[]="else"; ! 56: static TOK tswitch={0,0}; static char cswitch[]="switch"; ! 57: static TOK tcase={0,0}; static char ccase[]="case"; ! 58: static TOK tdefault={0,0}; static char cdefault[]="default"; ! 59: static TOK tbreak={0,0}; static char cbreak[]="break"; ! 60: static TOK tcontinue={0,0}; static char ccontinue[]="continue"; ! 61: static TOK ttypedef={0,0}; static char ctypedef[]="typedef"; ! 62: static TOK tsizeof={0,0}; static char csizeof[]="sizeof"; ! 63: static TOK tshort={0,0}; static char cshort[]="short"; ! 64: static TOK tconst={0,0}; static char cconst[]="const"; ! 65: static TOK tvolatile={0,0}; static char cvolatile[]="volatile"; ! 66: #ifdef READONLY ! 67: static TOK treadonly={0,0}; static char creadonly[]="readonly"; ! 68: #endif ! 69: #ifdef ALIEN ! 70: static TOK talien={0,0}; static char calien[]="alien"; ! 71: #endif ! 72: ! 73: /* ! 74: * Initialized symbols. ! 75: * Each of these gets linked in place ! 76: * into the symbol table, ! 77: * and the token each symbol specifies ! 78: * is entered into the token hash. ! 79: */ ! 80: static KEYSYM ktab[] = { ! 81: &txfile, SL_CPP, XUFILE, ! 82: &txuline, SL_CPP, XULINE, ! 83: &txdate, SL_CPP, XUDATE, ! 84: &txtime, SL_CPP, XUTIME, ! 85: &txstdc, SL_CPP, XUSTDC, ! 86: &txudefined, SL_CPP, XDEFINED, ! 87: &txdefine, SL_CPP, XDEFINE, ! 88: &txinclude, SL_CPP, XINCLUDE, ! 89: &txundef, SL_CPP, XUNDEF, ! 90: &txline, SL_CPP, XLINE, ! 91: &txassert, SL_CPP, XASSERT, ! 92: &txerror, SL_CPP, XERROR, ! 93: &txif, SL_CPP, XIF, ! 94: &txifdef, SL_CPP, XIFDEF, ! 95: &txifndef, SL_CPP, XIFNDEF, ! 96: &txelse, SL_CPP, XELSE, ! 97: &txelif, SL_CPP, XELIF, ! 98: &txendif, SL_CPP, XENDIF, ! 99: &tint, SL_KEY, INT, ! 100: &tchar, SL_KEY, CHAR, ! 101: &tfloat, SL_KEY, FLOAT, ! 102: &tdouble, SL_KEY, DOUBLE, ! 103: &tunsigned, SL_KEY, UNSIGNED, ! 104: &tsigned, SL_KEY, SIGNED, ! 105: &tregister, SL_KEY, REGISTER, ! 106: &tlong, SL_KEY, LONG, ! 107: &tstruct, SL_KEY, STRUCT, ! 108: &tunion, SL_KEY, UNION, ! 109: &tenum, SL_KEY, ENUM, ! 110: &tauto, SL_KEY, AUTO, ! 111: &tvoid, SL_KEY, VOID, ! 112: &tstatic, SL_KEY, STATIC, ! 113: &textern, SL_KEY, EXTERN, ! 114: &tgoto, SL_KEY, GOTO, ! 115: &treturn, SL_KEY, RETURN, ! 116: &tif, SL_KEY, IF, ! 117: &twhile, SL_KEY, WHILE, ! 118: &tfor, SL_KEY, FOR, ! 119: &tdo, SL_KEY, DO, ! 120: &telse, SL_KEY, ELSE, ! 121: &tswitch, SL_KEY, SWITCH, ! 122: &tcase, SL_KEY, CASE, ! 123: &tdefault, SL_KEY, DEFAULT, ! 124: &tbreak, SL_KEY, BREAK, ! 125: &tcontinue, SL_KEY, CONTINUE, ! 126: &ttypedef, SL_KEY, TYPEDEF, ! 127: &tsizeof, SL_KEY, SIZEOF, ! 128: &tshort, SL_KEY, SHORT, ! 129: &tconst, SL_KEY, CONST, ! 130: &tvolatile, SL_KEY, VOLATILE, ! 131: #ifdef READONLY ! 132: &treadonly, SL_KEY, READONLY, ! 133: #endif ! 134: #ifdef ALIEN ! 135: &talien, SL_KEY, ALIEN, ! 136: #endif ! 137: NULL ! 138: }; ! 139: ! 140: /* ! 141: * Enter reserved words into the hash table. ! 142: */ ! 143: kinit() ! 144: { ! 145: register char *p; ! 146: register int c; ! 147: register TOK *tp; ! 148: register KEYSYM *sp; ! 149: ! 150: sp = ktab; ! 151: while ((tp = sp->s_sp) != NULL) { ! 152: #ifdef VALIEN ! 153: if (sp->s_value==ALIEN && notvariant(VALIEN)) { ! 154: ++sp; ! 155: continue; ! 156: } ! 157: #endif ! 158: #ifdef VREADONLY ! 159: if (sp->s_value==READONLY && notvariant(VREADONLY)) { ! 160: ++sp; ! 161: continue; ! 162: } ! 163: #endif ! 164: p = tp->t_id; ! 165: idhash = 0; ! 166: while (c = *p++) ! 167: idhash += c; ! 168: idhash %= NHASH; ! 169: tp->t_tp = hash0[idhash]; ! 170: hash0[idhash] = tp; ! 171: tp->t_sym = sp; ! 172: sp->s_sp = NULL; ! 173: ++sp; ! 174: } ! 175: } ! 176:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.