|
|
1.1 ! root 1: #include "e.h" ! 2: #include "y.tab.h" ! 3: ! 4: tbl *keytbl[TBLSIZE]; /* key words */ ! 5: tbl *restbl[TBLSIZE]; /* reserved words */ ! 6: tbl *deftbl[TBLSIZE]; /* user-defined names */ ! 7: ! 8: struct keyword { ! 9: char *key; ! 10: int keyval; ! 11: } keyword[] ={ ! 12: "sub", SUB, ! 13: "sup", SUP, ! 14: ".EN", DOTEN, ! 15: ".EQ", DOTEQ, ! 16: "from", FROM, ! 17: "to", TO, ! 18: "sum", SUM, ! 19: "hat", HAT, ! 20: "vec", VEC, ! 21: "dyad", DYAD, ! 22: "dot", DOT, ! 23: "dotdot", DOTDOT, ! 24: "bar", BAR, ! 25: "lowbar", LOWBAR, ! 26: "highbar", HIGHBAR, ! 27: "tilde", TILDE, ! 28: "utilde", UTILDE, ! 29: "under", UNDER, ! 30: "prod", PROD, ! 31: "int", INT, ! 32: "integral", INT, ! 33: "union", UNION, ! 34: "inter", INTER, ! 35: "matrix", MATRIX, ! 36: "col", COL, ! 37: "lcol", LCOL, ! 38: "ccol", CCOL, ! 39: "rcol", RCOL, ! 40: "pile", COL, /* synonyms ... */ ! 41: "lpile", LCOL, ! 42: "cpile", CCOL, ! 43: "rpile", RCOL, ! 44: "over", OVER, ! 45: "sqrt", SQRT, ! 46: "above", ABOVE, ! 47: "size", SIZE, ! 48: "font", FONT, ! 49: "fat", FAT, ! 50: "roman", ROMAN, ! 51: "italic", ITALIC, ! 52: "bold", BOLD, ! 53: "left", LEFT, ! 54: "right", RIGHT, ! 55: "delim", DELIM, ! 56: "define", DEFINE, ! 57: "tdefine", DEFINE, ! 58: "ndefine", NDEFINE, ! 59: "ifdef", IFDEF, ! 60: "gsize", GSIZE, ! 61: ".gsize", GSIZE, ! 62: "gfont", GFONT, ! 63: "include", INCLUDE, ! 64: "copy", INCLUDE, ! 65: "space", SPACE, ! 66: "up", UP, ! 67: "down", DOWN, ! 68: "fwd", FWD, ! 69: "back", BACK, ! 70: "mark", MARK, ! 71: "lineup", LINEUP, ! 72: 0, 0 ! 73: }; ! 74: ! 75: struct resword { ! 76: char *res; ! 77: char *resval; ! 78: } resword[] ={ ! 79: ">=", "\\(>=", ! 80: "<=", "\\(<=", ! 81: "==", "\\(==", ! 82: "!=", "\\(!=", ! 83: "+-", "\\(+-", ! 84: "->", "\\(->", ! 85: "<-", "\\(<-", ! 86: "inf", "\\(if", ! 87: "infinity", "\\(if", ! 88: "partial", "\\(pd", ! 89: "half", "\\f1\\(12\\fP", ! 90: "prime", "\\f1\\v'.5m'\\s+3\\(fm\\s-3\\v'-.5m'\\fP", ! 91: "dollar", "\\f1$\\fP", ! 92: "nothing", "", ! 93: "times", "\\(mu", ! 94: "del", "\\(gr", ! 95: "grad", "\\(gr", ! 96: "approx", "\\v'-.2m'\\z\\(ap\\v'.25m'\\(ap\\v'-.05m'", ! 97: "cdot", "\\v'-.3m'.\\v'.3m'", ! 98: "...", "\\v'-.25m'\\ .\\ .\\ .\\ \\v'.25m'", ! 99: ",...,", "\\f1,\\fP\\ .\\ .\\ .\\ \\f1,\\fP\\|", ! 100: "alpha", "\\(*a", ! 101: "beta", "\\(*b", ! 102: "gamma", "\\(*g", ! 103: "GAMMA", "\\(*G", ! 104: "delta", "\\(*d", ! 105: "DELTA", "\\(*D", ! 106: "epsilon", "\\(*e", ! 107: "EPSILON", "\\f1E\\fP", ! 108: "omega", "\\(*w", ! 109: "OMEGA", "\\(*W", ! 110: "lambda", "\\(*l", ! 111: "LAMBDA", "\\(*L", ! 112: "mu", "\\(*m", ! 113: "nu", "\\(*n", ! 114: "theta", "\\(*h", ! 115: "THETA", "\\(*H", ! 116: "phi", "\\(*f", ! 117: "PHI", "\\(*F", ! 118: "pi", "\\(*p", ! 119: "PI", "\\(*P", ! 120: "sigma", "\\(*s", ! 121: "SIGMA", "\\(*S", ! 122: "xi", "\\(*c", ! 123: "XI", "\\(*C", ! 124: "zeta", "\\(*z", ! 125: "iota", "\\(*i", ! 126: "eta", "\\(*y", ! 127: "kappa", "\\(*k", ! 128: "rho", "\\(*r", ! 129: "tau", "\\(*t", ! 130: "omicron", "\\(*o", ! 131: "upsilon", "\\(*u", ! 132: "UPSILON", "\\(*U", ! 133: "psi", "\\(*q", ! 134: "PSI", "\\(*Q", ! 135: "chi", "\\(*x", ! 136: "and", "\\f1and\\fP", ! 137: "for", "\\f1for\\fP", ! 138: "if", "\\f1if\\fP", ! 139: "Re", "\\f1Re\\fP", ! 140: "Im", "\\f1Im\\fP", ! 141: "sin", "\\f1sin\\fP", ! 142: "cos", "\\f1cos\\fP", ! 143: "tan", "\\f1tan\\fP", ! 144: "arc", "\\f1arc\\fP", ! 145: "sinh", "\\f1sinh\\fP", ! 146: "coth", "\\f1coth\\fP", ! 147: "tanh", "\\f1tanh\\fP", ! 148: "cosh", "\\f1cosh\\fP", ! 149: "lim", "\\f1lim\\fP", ! 150: "log", "\\f1log\\fP", ! 151: "ln", "\\f1ln\\fP", ! 152: "max", "\\f1max\\fP", ! 153: "min", "\\f1min\\fP", ! 154: "exp", "\\f1exp\\fP", ! 155: "det", "\\f1det\\fP", ! 156: 0, 0 ! 157: }; ! 158: ! 159: int hash(char *s) ! 160: { ! 161: register unsigned int h; ! 162: ! 163: for (h = 0; *s != '\0'; ) ! 164: h += *s++; ! 165: h %= TBLSIZE; ! 166: return h; ! 167: } ! 168: ! 169: tbl *lookup(tbl **tblp, char *name) /* find name in tbl */ ! 170: { ! 171: register tbl *p; ! 172: ! 173: for (p = tblp[hash(name)]; p != NULL; p = p->next) ! 174: if (strcmp(name, p->name) == 0) ! 175: return(p); ! 176: return(NULL); ! 177: } ! 178: ! 179: void install(tbl **tblp, char *name, char *cval, int ival) /* install name, vals in tblp */ ! 180: { ! 181: register tbl *p; ! 182: int h; ! 183: ! 184: if ((p = lookup(tblp, name)) == NULL) { ! 185: p = (tbl *) malloc(sizeof(tbl)); ! 186: if (p == NULL) ! 187: ERROR "out of space in install" FATAL; ! 188: h = hash(name); /* bad visibility here */ ! 189: p->name = name; ! 190: p->next = tblp[h]; ! 191: tblp[h] = p; ! 192: } ! 193: p->cval = cval; ! 194: p->ival = ival; ! 195: } ! 196: ! 197: void init_tbl(void) /* initialize tables */ ! 198: { ! 199: int i; ! 200: extern int init_tune(void); ! 201: ! 202: for (i = 0; keyword[i].key != NULL; i++) ! 203: install(keytbl, keyword[i].key, (char *) 0, keyword[i].keyval); ! 204: for (i = 0; resword[i].res != NULL; i++) ! 205: install(restbl, resword[i].res, resword[i].resval, 0); ! 206: init_tune(); /* tuning table done in tuning.c */ ! 207: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.