/* Copyright (c) 1979 Regents of the University of California */
* pi - Pascal interpreter code translator
* Charles Haley, Bill Joy UCB
* Version 1.2 January 1979
* pxp - Pascal execution profiler
* Version 1.2 January 1979
* The definition for the segmented hash tables.
* This is the array of keywords and their
* token values, which are hashed into the table
"oct", YOCT
, /* non-standard Pascal */
"hex", YHEX
, /* non-standard Pascal */
char *lastkey
&yykey
[sizeof yykey
/sizeof yykey
[0]];
* Inithash initializes the hash table routines
* by allocating the first hash table segment using
* an already existing memory slot.
static int hshtab
[HASHINC
];
htab
[0].ht_high
= &hshtab
[HASHINC
];
for (ip
= yykey
; *ip
; ip
=+ 2)
* Hash looks up the s(ymbol) argument
* in the string table, entering it if
* it is not found. If save is 0, then
* the argument string is already in
* a safe place. Otherwise, if hash is
* entering the symbol for the first time
* it will save the symbol in the string
* The hash function is a modular hash of
* the sum of the characters with the sum
* doubled before each successive character
cp
= token
; /* default symbol to be hashed */
sh
= (i
&077777) % HASHINC
;
* There are as many as MAXHASH active
* hash tables at any given point in time.
* The search starts with the first table
* and continues through the active tables
for (htp
= htab
; htp
< &htab
[MAXHASH
]; htp
++) {
if (htp
->ht_low
== NIL
) {
yerror("Ran out of memory (hash)");
htp
->ht_high
= htp
->ht_low
+ HASHINC
;
* quadratic rehash increment
* starts at 1 and incremented
if (htp
->ht_used
> (HASHINC
* 3)/4)
if (sym
< lastkey
&& sym
>= yykey
)
if (sym
->pchar
== *cp
&& strcmp(sym
, cp
) == 0)
yerror("Ran out of hash tables");