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

Defined functions

init_tbl defined in line 220; used 1 times
lookup defined in line 188; used 9 times

Defined variables

deftbl defined in line 12; never used
keytbl defined in line 10; used 1 times
restbl defined in line 11; used 1 times
sccsid defined in line 2; never used

Defined macros

TBLSIZE defined in line 8; used 4 times
Last modified: 1983-08-12
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1061
Valid CSS Valid XHTML 1.0 Strict