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