Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / cemcom / idf.str
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5 /* $Id: idf.str,v 3.9 1994/06/24 12:04:03 ceriel Exp $ */
6 /* IDENTIFIER DESCRIPTOR */
7
8 #include        "nopp.h"
9
10 /*      Since the % operation in the calculation of the hash function
11         turns out to be expensive, it is replaced by the cheaper XOR (^).
12         Each character of the identifier is xored with an 8-bit mask which
13         depends on the position of the character; the sum of these results
14         is the hash value.  The random masks are obtained from a
15         congruence generator in idf.c.
16 */
17
18 #define HASHSIZE        256     /* must be a power of 2 */
19 #define HASH_X          0253    /* Knuth's X */
20 #define HASH_A          77      /* Knuth's a */
21 #define HASH_C          153     /* Knuth's c */
22
23 extern char hmask[];            /* the random masks */
24 #define HASHMASK                (HASHSIZE-1)    /* since it is a power of 2 */
25 #define STARTHASH()             (0)
26 #define ENHASH(hs,ch,ps)        (hs + (ch ^ hmask[ps]))
27 #define STOPHASH(hs)            (hs & HASHMASK)
28
29 struct idf      {
30         struct idf *next;
31         char *id_text;
32 #ifndef NOPP
33         struct macro *id_macro;
34         int id_resmac;          /* if nonzero: keyword of macroproc.    */
35 #endif /* NOPP */
36         int id_reserved;        /* non-zero for reserved words          */
37         char *id_file;          /* file containing the occurrence */
38         unsigned int id_line;   /* line number of the occurrence */
39         struct def *id_def;     /* variables, typedefs, enum-constants  */
40         struct sdef *id_sdef;   /* selector tags                        */
41         struct tag *id_struct;  /* struct and union tags                */
42         struct tag *id_enum;    /* enum tags                            */
43         int id_special;         /* special action needed at occurrence  */
44 };
45
46 /* ALLOCDEF "idf" 50 */
47
48 extern struct idf *str2idf(), *idf_hashed();
49
50 extern int level;
51 extern struct idf *gen_idf();