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