1987-03-25 23:14:43 +00:00
|
|
|
/*
|
|
|
|
* (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
|
|
|
|
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
|
|
|
*/
|
1994-06-24 14:02:31 +00:00
|
|
|
/* $Id$ */
|
1986-03-10 13:07:55 +00:00
|
|
|
/* IDENTIFIER DESCRIPTOR */
|
|
|
|
|
1988-08-19 13:55:22 +00:00
|
|
|
#include "nopp.h"
|
1986-03-10 13:07:55 +00:00
|
|
|
|
|
|
|
/* Since the % operation in the calculation of the hash function
|
|
|
|
turns out to be expensive, it is replaced by the cheaper XOR (^).
|
|
|
|
Each character of the identifier is xored with an 8-bit mask which
|
|
|
|
depends on the position of the character; the sum of these results
|
|
|
|
is the hash value. The random masks are obtained from a
|
|
|
|
congruence generator in idf.c.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define HASHSIZE 256 /* must be a power of 2 */
|
|
|
|
#define HASH_X 0253 /* Knuth's X */
|
|
|
|
#define HASH_A 77 /* Knuth's a */
|
|
|
|
#define HASH_C 153 /* Knuth's c */
|
|
|
|
|
|
|
|
extern char hmask[]; /* the random masks */
|
|
|
|
#define HASHMASK (HASHSIZE-1) /* since it is a power of 2 */
|
|
|
|
#define STARTHASH() (0)
|
|
|
|
#define ENHASH(hs,ch,ps) (hs + (ch ^ hmask[ps]))
|
|
|
|
#define STOPHASH(hs) (hs & HASHMASK)
|
|
|
|
|
|
|
|
struct idf {
|
|
|
|
struct idf *next;
|
|
|
|
char *id_text;
|
|
|
|
#ifndef NOPP
|
|
|
|
struct macro *id_macro;
|
|
|
|
int id_resmac; /* if nonzero: keyword of macroproc. */
|
1991-12-17 14:11:15 +00:00
|
|
|
#endif /* NOPP */
|
1986-03-10 13:07:55 +00:00
|
|
|
int id_reserved; /* non-zero for reserved words */
|
1988-09-16 23:19:50 +00:00
|
|
|
char *id_file; /* file containing the occurrence */
|
|
|
|
unsigned int id_line; /* line number of the occurrence */
|
1986-03-10 13:07:55 +00:00
|
|
|
struct def *id_def; /* variables, typedefs, enum-constants */
|
|
|
|
struct sdef *id_sdef; /* selector tags */
|
|
|
|
struct tag *id_struct; /* struct and union tags */
|
|
|
|
struct tag *id_enum; /* enum tags */
|
|
|
|
int id_special; /* special action needed at occurrence */
|
|
|
|
};
|
|
|
|
|
1987-01-24 00:25:56 +00:00
|
|
|
/* ALLOCDEF "idf" 50 */
|
1986-03-10 13:07:55 +00:00
|
|
|
|
|
|
|
extern struct idf *str2idf(), *idf_hashed();
|
|
|
|
|
|
|
|
extern int level;
|
|
|
|
extern struct idf *gen_idf();
|