1: /*
   2:  * Copyright (c) 1983 Regents of the University of California,
   3:  * All rights reserved.  Redistribution permitted subject to
   4:  * the terms of the Berkeley Software License Agreement.
   5:  */
   6: 
   7: #if !defined(lint) && !defined(pdp11)
   8: static char sccsid[] = "@(#)parse.c	1.2 4/24/85";
   9: #endif
  10: 
  11: #include "externs.h"
  12: 
  13: wordinit()
  14: {
  15:     register struct wlist *w;
  16: 
  17:     for (w = wlist; w->string; w++)
  18:         install(w);
  19: }
  20: 
  21: hash(s)
  22:     register char *s;
  23: {
  24:     register hashval = 0;
  25: 
  26:     while (*s) {
  27:         hashval += *s++;
  28:         hashval *= HASHMUL;
  29:         hashval &= HASHMASK;
  30:     }
  31:     return hashval;
  32: }
  33: 
  34: struct wlist *
  35: lookup(s)
  36:     char *s;
  37: {
  38:     register struct wlist *wp;
  39: 
  40:     for (wp = hashtab[hash(s)]; wp != NULL; wp = wp->next)
  41:         if (*s == *wp->string && strcmp(s, wp->string) == 0)
  42:             return wp;
  43:     return NULL;
  44: }
  45: 
  46: install(wp)
  47:     register struct wlist *wp;
  48: {
  49:     int hashval;
  50: 
  51:     if (lookup(wp->string) == NULL) {
  52:         hashval = hash(wp->string);
  53:         wp->next = hashtab[hashval];
  54:         hashtab[hashval] = wp;
  55:     } else
  56:         printf("Multiply defined %s.\n", wp->string);
  57: }
  58: 
  59: parse()
  60: {
  61:     register struct wlist *wp;
  62:     register n;
  63: 
  64:     wordnumber = 0;           /* for cypher */
  65:     for (n = 0; n <= wordcount; n++) {
  66:         if ((wp = lookup(words[n])) == NULL) {
  67:             wordvalue[n] = -1;
  68:             wordtype[n] = -1;
  69:         } else {
  70:             wordvalue[n] = wp -> value;
  71:             wordtype[n] = wp -> article;
  72:         }
  73:     }
  74: }

Defined functions

hash defined in line 21; used 2 times
install defined in line 46; used 1 times
  • in line 18
lookup defined in line 34; used 2 times
wordinit defined in line 13; used 1 times

Defined variables

sccsid defined in line 8; never used
Last modified: 1987-07-31
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2864
Valid CSS Valid XHTML 1.0 Strict