home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / c-gperf.h < prev    next >
C/C++ Source or Header  |  1996-06-21  |  6KB  |  197 lines

  1. #ifdef NEXT_SEMANTICS
  2. #include "c-gperf-next.h"
  3. #elif defined (_WIN32) && defined (NEXT_PDO)
  4. #include "c-gperf-winntpdo.h"
  5. #else
  6. /* C code produced by gperf version 2.5 (GNU C++ version) */
  7. /* Command-line: gperf -p -j1 -i 1 -g -o -t -G -N is_reserved_word -k1,3,$ c-parse.gperf  */ 
  8. struct resword { char *name; short token; enum rid rid; };
  9.  
  10. #define TOTAL_KEYWORDS 80
  11. #define MIN_WORD_LENGTH 2
  12. #define MAX_WORD_LENGTH 20
  13. #define MIN_HASH_VALUE 10
  14. #define MAX_HASH_VALUE 162
  15. /* maximum key range = 153, duplicates = 0 */
  16.  
  17. #ifdef __GNUC__
  18. inline
  19. #endif
  20. static unsigned int
  21. hash (str, len)
  22.      register char *str;
  23.      register int unsigned len;
  24. {
  25.   static unsigned char asso_values[] =
  26.     {
  27.      163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
  28.      163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
  29.      163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
  30.      163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
  31.      163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
  32.      163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
  33.      163, 163, 163, 163,   8, 163, 163, 163, 163, 163,
  34.      163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
  35.      163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
  36.      163, 163, 163, 163, 163,   1, 163,  24,   8,  61,
  37.       37,   6,  47,  49,   2,   5, 163,   3,  51,  30,
  38.       58,  91,  35, 163,  33,  13,   1,  18,  49,   2,
  39.        2,   5,   3, 163, 163, 163, 163, 163,
  40.     };
  41.   register int hval = len;
  42.  
  43.   switch (hval)
  44.     {
  45.       default:
  46.       case 3:
  47.         hval += asso_values[str[2]];
  48.       case 2:
  49.       case 1:
  50.         hval += asso_values[str[0]];
  51.         break;
  52.     }
  53.   return hval + asso_values[str[len - 1]];
  54. }
  55.  
  56. static struct resword wordlist[] =
  57. {
  58.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  59.       {"",}, 
  60.       {"int",  TYPESPEC, RID_INT},
  61.       {"",}, {"",}, 
  62.       {"__typeof__",  TYPEOF, NORID},
  63.       {"",}, 
  64.       {"__imag__",  IMAGPART, NORID},
  65.       {"",}, 
  66.       {"__inline__",  SCSPEC, RID_INLINE},
  67.       {"while",  WHILE, NORID},
  68.       {"__iterator__",  SCSPEC, RID_ITERATOR},
  69.       {"__inline",  SCSPEC, RID_INLINE},
  70.       {"__extension__",  EXTENSION, NORID},
  71.       {"break",  BREAK, NORID},
  72.       {"",}, {"",}, 
  73.       {"__signed__",  TYPESPEC, RID_SIGNED},
  74.       {"switch",  SWITCH, NORID},
  75.       {"",}, {"",}, 
  76.       {"else",  ELSE, NORID},
  77.       {"",}, {"",}, 
  78.       {"@defs",  DEFS, NORID},
  79.       {"__asm__",  ASM_KEYWORD, NORID},
  80.       {"",}, {"",}, {"",}, 
  81.       {"__alignof__",  ALIGNOF, NORID},
  82.       {"",}, 
  83.       {"__attribute__",  ATTRIBUTE, NORID},
  84.       {"",}, {"",}, 
  85.       {"__attribute",  ATTRIBUTE, NORID},
  86.       {"__real__",  REALPART, NORID},
  87.       {"id",  OBJECTNAME, RID_ID},
  88.       {"",}, {"",}, {"",}, {"",}, 
  89.       {"__iterator",  SCSPEC, RID_ITERATOR},
  90.       {"",}, {"",}, {"",}, 
  91.       {"struct",  STRUCT, NORID},
  92.       {"if",  IF, NORID},
  93.       {"@private",  PRIVATE, NORID},
  94.       {"@selector",  SELECTOR, NORID},
  95.       {"__typeof",  TYPEOF, NORID},
  96.       {"enum",  ENUM, NORID},
  97.       {"__signed",  TYPESPEC, RID_SIGNED},
  98.       {"__asm",  ASM_KEYWORD, NORID},
  99.       {"__imag",  IMAGPART, NORID},
  100.       {"__label__",  LABEL, NORID},
  101.       {"__volatile__",  TYPE_QUAL, RID_VOLATILE},
  102.       {"",}, 
  103.       {"in",  TYPE_QUAL, RID_IN},
  104.       {"__volatile",  TYPE_QUAL, RID_VOLATILE},
  105.       {"double",  TYPESPEC, RID_DOUBLE},
  106.       {"inline",  SCSPEC, RID_INLINE},
  107.       {"sizeof",  SIZEOF, NORID},
  108.       {"__const",  TYPE_QUAL, RID_CONST},
  109.       {"extern",  SCSPEC, RID_EXTERN},
  110.       {"__const__",  TYPE_QUAL, RID_CONST},
  111.       {"__complex",  TYPESPEC, RID_COMPLEX},
  112.       {"__complex__",  TYPESPEC, RID_COMPLEX},
  113.       {"",}, 
  114.       {"unsigned",  TYPESPEC, RID_UNSIGNED},
  115.       {"",}, 
  116.       {"@class",  CLASS, NORID},
  117.       {"@encode",  ENCODE, NORID},
  118.       {"bycopy",  TYPE_QUAL, RID_BYCOPY},
  119.       {"__alignof",  ALIGNOF, NORID},
  120.       {"@interface",  INTERFACE, NORID},
  121.       {"",}, 
  122.       {"case",  CASE, NORID},
  123.       {"",}, 
  124.       {"union",  UNION, NORID},
  125.       {"asm",  ASM_KEYWORD, NORID},
  126.       {"@protected",  PROTECTED, NORID},
  127.       {"typeof",  TYPEOF, NORID},
  128.       {"typedef",  SCSPEC, RID_TYPEDEF},
  129.       {"__real",  REALPART, NORID},
  130.       {"default",  DEFAULT, NORID},
  131.       {"byref",  TYPE_QUAL, RID_BYREF},
  132.       {"@public",  PUBLIC, NORID},
  133.       {"void",  TYPESPEC, RID_VOID},
  134.       {"out",  TYPE_QUAL, RID_OUT},
  135.       {"",}, 
  136.       {"return",  RETURN, NORID},
  137.       {"",}, {"",}, 
  138.       {"@protocol",  PROTOCOL, NORID},
  139.       {"inout",  TYPE_QUAL, RID_INOUT},
  140.       {"",}, 
  141.       {"static",  SCSPEC, RID_STATIC},
  142.       {"signed",  TYPESPEC, RID_SIGNED},
  143.       {"",}, 
  144.       {"@end",  END, NORID},
  145.       {"oneway",  TYPE_QUAL, RID_ONEWAY},
  146.       {"",}, 
  147.       {"short",  TYPESPEC, RID_SHORT},
  148.       {"@implementation",  IMPLEMENTATION, NORID},
  149.       {"",}, {"",}, 
  150.       {"volatile",  TYPE_QUAL, RID_VOLATILE},
  151.       {"",}, 
  152.       {"for",  FOR, NORID},
  153.       {"",}, {"",}, {"",}, 
  154.       {"auto",  SCSPEC, RID_AUTO},
  155.       {"",}, 
  156.       {"char",  TYPESPEC, RID_CHAR},
  157.       {"register",  SCSPEC, RID_REGISTER},
  158.       {"",}, 
  159.       {"const",  TYPE_QUAL, RID_CONST},
  160.       {"",}, {"",}, {"",}, {"",}, 
  161.       {"do",  DO, NORID},
  162.       {"",}, 
  163.       {"@compatibility_alias",  ALIAS, NORID},
  164.       {"continue",  CONTINUE, NORID},
  165.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  166.       {"",}, 
  167.       {"float",  TYPESPEC, RID_FLOAT},
  168.       {"goto",  GOTO, NORID},
  169.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  170.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  171.       {"long",  TYPESPEC, RID_LONG},
  172. };
  173.  
  174. #ifdef __GNUC__
  175. inline
  176. #endif
  177. struct resword *
  178. is_reserved_word (str, len)
  179.      register char *str;
  180.      register unsigned int len;
  181. {
  182.   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
  183.     {
  184.       register int key = hash (str, len);
  185.  
  186.       if (key <= MAX_HASH_VALUE && key >= 0)
  187.         {
  188.           register char *s = wordlist[key].name;
  189.  
  190.           if (*s == *str && !strcmp (str + 1, s + 1))
  191.             return &wordlist[key];
  192.         }
  193.     }
  194.   return 0;
  195. }
  196. #endif
  197.