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

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