idf.str 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* $Header$ */
  2. /* IDENTIFIER DESCRIPTOR */
  3. #include "nopp.h"
  4. /* Since the % operation in the calculation of the hash function
  5. turns out to be expensive, it is replaced by the cheaper XOR (^).
  6. Each character of the identifier is xored with an 8-bit mask which
  7. depends on the position of the character; the sum of these results
  8. is the hash value. The random masks are obtained from a
  9. congruence generator in idf.c.
  10. */
  11. #define HASHSIZE 256 /* must be a power of 2 */
  12. #define HASH_X 0253 /* Knuth's X */
  13. #define HASH_A 77 /* Knuth's a */
  14. #define HASH_C 153 /* Knuth's c */
  15. extern char hmask[]; /* the random masks */
  16. #define HASHMASK (HASHSIZE-1) /* since it is a power of 2 */
  17. #define STARTHASH() (0)
  18. #define ENHASH(hs,ch,ps) (hs + (ch ^ hmask[ps]))
  19. #define STOPHASH(hs) (hs & HASHMASK)
  20. struct idf {
  21. struct idf *next;
  22. char *id_text;
  23. #ifndef NOPP
  24. struct macro *id_macro;
  25. int id_resmac; /* if nonzero: keyword of macroproc. */
  26. #endif NOPP
  27. int id_reserved; /* non-zero for reserved words */
  28. struct def *id_def; /* variables, typedefs, enum-constants */
  29. struct sdef *id_sdef; /* selector tags */
  30. struct tag *id_struct; /* struct and union tags */
  31. struct tag *id_enum; /* enum tags */
  32. int id_special; /* special action needed at occurrence */
  33. };
  34. /* ALLOCDEF "idf" 50 */
  35. extern struct idf *str2idf(), *idf_hashed();
  36. extern int level;
  37. extern struct idf *gen_idf();