idf.str 1.6 KB

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