|
|
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", DOTEN, ! 17: ".EQ", DOTEQ, ! 18: "from", FROM, ! 19: "to", TO, ! 20: "sum", SUM, ! 21: "hat", HAT, ! 22: "vec", VEC, ! 23: "dyad", DYAD, ! 24: "dot", DOT, ! 25: "dotdot", DOTDOT, ! 26: "bar", BAR, ! 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: ! 58: #ifdef NEQN /* make ndefine synonym for define, tdefine a no-op */ ! 59: ! 60: "tdefine", TDEFINE, ! 61: "ndefine", DEFINE, ! 62: ! 63: #else /* tdefine = define, ndefine = no-op */ ! 64: ! 65: "tdefine", DEFINE, ! 66: "ndefine", NDEFINE, ! 67: ! 68: #endif ! 69: ! 70: "ifdef", IFDEF, ! 71: "gsize", GSIZE, ! 72: ".gsize", GSIZE, ! 73: "gfont", GFONT, ! 74: "include", INCLUDE, ! 75: "copy", INCLUDE, ! 76: "space", SPACE, ! 77: "up", UP, ! 78: "down", DOWN, ! 79: "fwd", FWD, ! 80: "back", BACK, ! 81: "mark", MARK, ! 82: "lineup", LINEUP, ! 83: 0, 0 ! 84: }; ! 85: ! 86: struct { ! 87: char *res; ! 88: char *resval; ! 89: } resword[] ={ ! 90: ">=", "\\(>=", ! 91: "<=", "\\(<=", ! 92: "==", "\\(==", ! 93: "!=", "\\(!=", ! 94: "+-", "\\(+-", ! 95: "->", "\\(->", ! 96: "<-", "\\(<-", ! 97: "inf", "\\(if", ! 98: "infinity", "\\(if", ! 99: "partial", "\\(pd", ! 100: "half", "\\f1\\(12\\fP", ! 101: "prime", "\\f1\\v'.5m'\\s+3\\(fm\\s-3\\v'-.5m'\\fP", ! 102: "dollar", "\\f1$\\fP", ! 103: "nothing", "", ! 104: "times", "\\(mu", ! 105: "del", "\\(gr", ! 106: "grad", "\\(gr", ! 107: ! 108: #ifdef NEQN ! 109: "<<", "<<", ! 110: ">>", ">>", ! 111: "approx", "~\b\\d~\\u", ! 112: "cdot", "\\v'-.5'.\\v'.5'", ! 113: "...", "...", ! 114: ",...,", ",...,", ! 115: #else ! 116: "<<", "<\\h'-.3m'<", ! 117: ">>", ">\\h'-.3m'>", ! 118: "approx", "\\v'-.2m'\\z\\(ap\\v'.25m'\\(ap\\v'-.05m'", ! 119: "cdot", "\\v'-.3m'.\\v'.3m'", ! 120: "...", "\\v'-.3m'\\ .\\ .\\ .\\ \\v'.3m'", ! 121: ",...,", "\\f1,\\fP\\ .\\ .\\ .\\ \\f1,\\fP\\|", ! 122: #endif ! 123: ! 124: "alpha", "\\(*a", ! 125: "beta", "\\(*b", ! 126: "gamma", "\\(*g", ! 127: "GAMMA", "\\(*G", ! 128: "delta", "\\(*d", ! 129: "DELTA", "\\(*D", ! 130: "epsilon", "\\(*e", ! 131: "EPSILON", "\\f1E\\fP", ! 132: "omega", "\\(*w", ! 133: "OMEGA", "\\(*W", ! 134: "lambda", "\\(*l", ! 135: "LAMBDA", "\\(*L", ! 136: "mu", "\\(*m", ! 137: "nu", "\\(*n", ! 138: "theta", "\\(*h", ! 139: "THETA", "\\(*H", ! 140: "phi", "\\(*f", ! 141: "PHI", "\\(*F", ! 142: "pi", "\\(*p", ! 143: "PI", "\\(*P", ! 144: "sigma", "\\(*s", ! 145: "SIGMA", "\\(*S", ! 146: "xi", "\\(*c", ! 147: "XI", "\\(*C", ! 148: "zeta", "\\(*z", ! 149: "iota", "\\(*i", ! 150: "eta", "\\(*y", ! 151: "kappa", "\\(*k", ! 152: "rho", "\\(*r", ! 153: "tau", "\\(*t", ! 154: "omicron", "\\(*o", ! 155: "upsilon", "\\(*u", ! 156: "UPSILON", "\\(*U", ! 157: "psi", "\\(*q", ! 158: "PSI", "\\(*Q", ! 159: "chi", "\\(*x", ! 160: "and", "\\f1and\\fP", ! 161: "for", "\\f1for\\fP", ! 162: "if", "\\f1if\\fP", ! 163: "Re", "\\f1Re\\fP", ! 164: "Im", "\\f1Im\\fP", ! 165: "sin", "\\f1sin\\fP", ! 166: "cos", "\\f1cos\\fP", ! 167: "tan", "\\f1tan\\fP", ! 168: "arc", "\\f1arc\\fP", ! 169: "sinh", "\\f1sinh\\fP", ! 170: "coth", "\\f1coth\\fP", ! 171: "tanh", "\\f1tanh\\fP", ! 172: "cosh", "\\f1cosh\\fP", ! 173: "lim", "\\f1lim\\fP", ! 174: "log", "\\f1log\\fP", ! 175: "max", "\\f1max\\fP", ! 176: "min", "\\f1min\\fP", ! 177: "ln", "\\f1ln\\fP", ! 178: "exp", "\\f1exp\\fP", ! 179: "det", "\\f1det\\fP", ! 180: 0, 0 ! 181: }; ! 182: ! 183: tbl *lookup(tblp, name, defn) /* find name in tbl. if defn non-null, install */ ! 184: tbl **tblp; ! 185: char *name, *defn; ! 186: { ! 187: register tbl *p; ! 188: register int h; ! 189: register char *s = name; ! 190: ! 191: for (h = 0; *s != '\0'; ) ! 192: h += *s++; ! 193: h %= TBLSIZE; ! 194: ! 195: for (p = tblp[h]; p != NULL; p = p->next) ! 196: if (strcmp(name, p->name) == 0) { /* found it */ ! 197: if (defn != NULL) ! 198: p->defn = defn; ! 199: return(p); ! 200: } ! 201: /* didn't find it */ ! 202: if (defn == NULL) ! 203: return(NULL); ! 204: p = (tbl *) malloc(sizeof (tbl)); ! 205: if (p == NULL) ! 206: error(FATAL, "out of space in lookup"); ! 207: p->name = name; ! 208: p->defn = defn; ! 209: p->next = tblp[h]; ! 210: tblp[h] = p; ! 211: return(p); ! 212: } ! 213: ! 214: init_tbl() /* initialize all tables */ ! 215: { ! 216: int i; ! 217: ! 218: for (i = 0; keyword[i].key != NULL; i++) ! 219: lookup(keytbl, keyword[i].key, keyword[i].keyval); ! 220: for (i = 0; resword[i].res != NULL; i++) ! 221: lookup(restbl, resword[i].res, resword[i].resval); ! 222: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.