home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / obcp / hash-next.h < prev    next >
C/C++ Source or Header  |  1996-05-15  |  9KB  |  249 lines

  1. /* C code produced by gperf version 2.5 (GNU C++ version) */
  2. /* Command-line: gperf -p -j1 -g -G -o -t -N is_reserved_word -k1,4,$,7 obcp.gperf  */
  3. /* Command-line: gperf -p -j1 -g -G -o -t -N is_reserved_word '-k1,4,$,7' obcp.gperf  */
  4. struct resword { char *name; short token; enum rid rid; enum languages lang; char *save; };
  5.  
  6. #define TOTAL_KEYWORDS 111
  7. #define MIN_WORD_LENGTH 2
  8. #define MAX_WORD_LENGTH 15
  9. #define MIN_HASH_VALUE 4
  10. #define MAX_HASH_VALUE 246
  11. /* maximum key range = 243, duplicates = 0 */
  12.  
  13. #ifdef __GNUC__
  14. inline
  15. #endif
  16. static unsigned int
  17. hash (str, len)
  18.      register char *str;
  19.      register int unsigned len;
  20. {
  21.   static unsigned char asso_values[] =
  22.     {
  23.      247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
  24.      247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
  25.      247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
  26.      247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
  27.      247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
  28.      247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
  29.      247, 247, 247, 247,  87, 247, 247, 247, 247, 247,
  30.      247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
  31.      247, 247, 247, 247, 247, 247, 247, 247, 247, 247,
  32.      247, 247, 247, 247, 247,   0, 247,  31,   5,  26,
  33.       58,   0,  99,   0,   1,  45, 247,   0,   6,  57,
  34.       57,   2,  30,  17,  66,  10,   1,  84,   7,  24,
  35.        6,  24, 247, 247, 247, 247, 247, 247,
  36.     };
  37.   register int hval = len;
  38.  
  39.   switch (hval)
  40.     {
  41.       default:
  42.       case 7:
  43.         hval += asso_values[str[6]];
  44.       case 6:
  45.       case 5:
  46.       case 4:
  47.         hval += asso_values[str[3]];
  48.       case 3:
  49.       case 2:
  50.       case 1:
  51.         hval += asso_values[str[0]];
  52.         break;
  53.     }
  54.   return hval + asso_values[str[len - 1]];
  55. }
  56.  
  57. static struct resword wordlist[] =
  58. {
  59.       {"",}, {"",}, {"",}, {"",}, 
  60.       {"else",  ELSE, NORID, lang_c,},
  61.       {"true",  CXX_TRUE, NORID, lang_c,},
  62.       {"out",  TYPE_QUAL, RID_OUT, lang_objc,},
  63.       {"",}, 
  64.       {"goto",  GOTO, NORID, lang_c,},
  65.       {"",}, 
  66.       {"long",  TYPESPEC, RID_LONG, lang_c,},
  67.       {"__const",  TYPE_QUAL, RID_CONST, lang_c,},
  68.       {"__const__",  TYPE_QUAL, RID_CONST, lang_c,},
  69.       {"__volatile",  TYPE_QUAL, RID_VOLATILE, lang_c,},
  70.       {"",}, 
  71.       {"__volatile__",  TYPE_QUAL, RID_VOLATILE, lang_c,},
  72.       {"",}, 
  73.       {"__asm__",  GCC_ASM_KEYWORD, NORID, lang_c,},
  74.       {"switch",  SWITCH, NORID, lang_c, },
  75.       {"",}, {"",}, 
  76.       {"bool",  TYPESPEC, RID_BOOL, lang_c,},
  77.       {"",}, 
  78.       {"static_cast",  STATIC_CAST, NORID, lang_cplusplus,},
  79.       {"or_eq",  ASSIGN, NORID, lang_c,},
  80.       {"this",  THIS, NORID, lang_cplusplus, },
  81.       {"",}, 
  82.       {"virtual",  SCSPEC, RID_VIRTUAL, lang_cplusplus, },
  83.       {"try",  TRY, NORID, lang_cplusplus,        /* Extension */},
  84.       {"xor_eq",  ASSIGN, NORID, lang_c,},
  85.       {"case",  CASE, NORID, lang_c,},
  86.       {"",}, 
  87.       {"throw",  THROW, NORID, lang_cplusplus,        /* Extension */},
  88.       {"",}, {"",}, 
  89.       {"while",  WHILE, NORID, lang_c, },
  90.       {"__typeof__",  TYPEOF, NORID, lang_c,},
  91.       {"bycopy",  TYPE_QUAL, RID_BYCOPY, lang_objc,},
  92.       {"",}, 
  93.       {"auto",  SCSPEC, RID_AUTO, lang_c,},
  94.       {"template",  TEMPLATE, NORID, lang_cplusplus, },
  95.       {"break",  BREAK, NORID, lang_c,},
  96.       {"const",  TYPE_QUAL, RID_CONST, lang_c,},
  97.       {"static",  SCSPEC, RID_STATIC, lang_c, },
  98.       {"private",  VISSPEC, RID_PRIVATE, lang_cplusplus,},
  99.       {"",}, 
  100.       {"__label__",  LABEL, NORID, lang_c,},
  101.       {"",}, {"",}, 
  102.       {"int",  TYPESPEC, RID_INT, lang_c,},
  103.       {"",}, 
  104.       {"class",  AGGR, RID_CLASS, lang_cplusplus,},
  105.       {"volatile",  TYPE_QUAL, RID_VOLATILE, lang_c, },
  106.       {"",}, 
  107.       {"and_eq",  ASSIGN, NORID, lang_c,},
  108.       {"__signed__",  TYPESPEC, RID_SIGNED, lang_c,},
  109.       {"oneway",  TYPE_QUAL, RID_ONEWAY, lang_objc,},
  110.       {"__attribute",  ATTRIBUTE, NORID, lang_c,},
  111.       {"catch",  CATCH, NORID, lang_cplusplus,},
  112.       {"__attribute__",  ATTRIBUTE, NORID, lang_c,},
  113.       {"",}, 
  114.       {"not",  '!', NORID, lang_c,},
  115.       {"do",  DO, NORID, lang_c,},
  116.       {"extern",  SCSPEC, RID_EXTERN, lang_c,},
  117.       {"delete",  DELETE, NORID, lang_cplusplus,},
  118.       {"typeid",  TYPEID, NORID, lang_cplusplus,},
  119.       {"typename",  TYPENAME_KEYWORD, NORID, lang_cplusplus,},
  120.       {"compl",  '~', NORID, lang_c,},
  121.       {"public",  VISSPEC, RID_PUBLIC, lang_cplusplus, },
  122.       {"double",  TYPESPEC, RID_DOUBLE, lang_c,},
  123.       {"or",  OROR, NORID, lang_c,},
  124.       {"",}, 
  125.       {"__asm",  GCC_ASM_KEYWORD, NORID, lang_c,},
  126.       {"const_cast",  CONST_CAST, NORID, lang_cplusplus,},
  127.       {"__alignof__",  ALIGNOF, NORID, lang_c,},
  128.       {"xor",  '^', NORID, lang_c,},
  129.       {"__extension__",  EXTENSION, NORID, lang_c,},
  130.       {"",}, 
  131.       {"bitor",  '|', NORID, lang_c,},
  132.       {"",}, 
  133.       {"not_eq",  EQCOMPARE, NORID, lang_c,},
  134.       {"__direct__",  SCSPEC, RID_DIRECT, lang_objc,},
  135.       {"short",  TYPESPEC, RID_SHORT, lang_c, },
  136.       {"",}, 
  137.       {"new",  NEW, NORID, lang_cplusplus,},
  138.       {"",}, {"",}, {"",}, {"",}, 
  139.       {"__signature__",  AGGR, RID_SIGNATURE, lang_cplusplus    /* Extension */,},
  140.       {"",}, 
  141.       {"asm",  ASM_KEYWORD, NORID, lang_c,},
  142.       {"and",  ANDAND, NORID, lang_c,},
  143.       {"",}, {"",}, 
  144.       {"mutable",  SCSPEC, RID_MUTABLE, lang_cplusplus,},
  145.       {"inline",  SCSPEC, RID_INLINE, lang_c,},
  146.       {"namespace",  NAMESPACE, NORID, lang_cplusplus,},
  147.       {"default",  DEFAULT, NORID, lang_c,},
  148.       {"protected",  VISSPEC, RID_PROTECTED, lang_cplusplus,},
  149.       {"bitand",  '&', NORID, lang_c,},
  150.       {"struct",  AGGR, RID_RECORD, lang_c, },
  151.       {"__wchar_t",  TYPESPEC, RID_WCHAR, lang_cplusplus, /* Unique to ANSI C++ */},
  152.       {"",}, 
  153.       {"in",  TYPE_QUAL, RID_IN, lang_objc,},
  154.       {"id",  OBJECTNAME, RID_ID, lang_objc,},
  155.       {"typeof",  TYPEOF, NORID, lang_c, },
  156.       {"",}, {"",}, 
  157.       {"byref",  TYPE_QUAL, RID_BYREF, lang_objc,},
  158.       {"",}, 
  159.       {"__signed",  TYPESPEC, RID_SIGNED, lang_c,},
  160.       {"",}, {"",}, 
  161.       {"false",  CXX_FALSE, NORID, lang_c,},
  162.       {"sizeof",  SIZEOF, NORID, lang_c, },
  163.       {"sigof",  SIGOF, NORID, lang_cplusplus,        /* Extension */},
  164.       {"",}, 
  165.       {"enum",  ENUM, NORID, lang_c,},
  166.       {"continue",  CONTINUE, NORID, lang_c,},
  167.       {"@encode",  ENCODE, NORID, lang_objc,},
  168.       {"",}, 
  169.       {"__inline",  SCSPEC, RID_INLINE, lang_c,},
  170.       {"",}, 
  171.       {"__inline__",  SCSPEC, RID_INLINE, lang_c,},
  172.       {"",}, {"",}, 
  173.       {"void",  TYPESPEC, RID_VOID, lang_c, },
  174.       {"dynamic_cast",  DYNAMIC_CAST, NORID, lang_cplusplus,},
  175.       {"",}, 
  176.       {"@protocol",  PROTOCOL, NORID, lang_objc,},
  177.       {"signed",  TYPESPEC, RID_SIGNED, lang_c, },
  178.       {"",}, 
  179.       {"__typeof",  TYPEOF, NORID, lang_c,},
  180.       {"@class",  CLASS, NORID, lang_objc,},
  181.       {"inout",  TYPE_QUAL, RID_INOUT, lang_objc,},
  182.       {"float",  TYPESPEC, RID_FLOAT, lang_c,},
  183.       {"",}, {"",}, {"",}, {"",}, 
  184.       {"@private",  PRIVATE, NORID, lang_objc,},
  185.       {"",}, {"",}, 
  186.       {"operator",  OPERATOR, NORID, lang_cplusplus,},
  187.       {"",}, 
  188.       {"if",  IF, NORID, lang_c,},
  189.       {"",}, 
  190.       {"union",  AGGR, RID_UNION, lang_c, },
  191.       {"",}, {"",}, 
  192.       {"@public",  PUBLIC, NORID, lang_objc,},
  193.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  194.       {"",}, 
  195.       {"char",  TYPESPEC, RID_CHAR, lang_c,},
  196.       {"friend",  SCSPEC, RID_FRIEND, lang_cplusplus,},
  197.       {"",}, 
  198.       {"overload",  OVERLOAD, NORID, lang_cplusplus,},
  199.       {"",}, {"",}, 
  200.       {"for",  FOR, NORID, lang_c,},
  201.       {"@selector",  SELECTOR, NORID, lang_objc, },
  202.       {"",}, 
  203.       {"__alignof",  ALIGNOF, NORID, lang_c,},
  204.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  205.       {"",}, {"",}, 
  206.       {"@protected",  PROTECTED, NORID, lang_objc,},
  207.       {"",}, 
  208.       {"register",  SCSPEC, RID_REGISTER, lang_c, },
  209.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  210.       {"unsigned",  TYPESPEC, RID_UNSIGNED, lang_c, },
  211.       {"",}, 
  212.       {"@interface",  INTERFACE, NORID, lang_objc,},
  213.       {"",}, {"",}, {"",}, 
  214.       {"@defs",  DEFS, NORID, lang_objc,},
  215.       {"",}, {"",}, {"",}, {"",}, 
  216.       {"typedef",  SCSPEC, RID_TYPEDEF, lang_c, },
  217.       {"@end",  END, NORID, lang_objc,},
  218.       {"",}, {"",}, {"",}, {"",}, {"",}, 
  219.       {"return",  RETURN, NORID, lang_c, },
  220.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  221.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  222.       {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
  223.       {"",}, {"",}, {"",}, {"",}, {"",}, 
  224.       {"@implementation",  IMPLEMENTATION, NORID, lang_objc,},
  225. };
  226.  
  227. #ifdef __GNUC__
  228. inline
  229. #endif
  230. struct resword *
  231. is_reserved_word (str, len)
  232.      register char *str;
  233.      register unsigned int len;
  234. {
  235.   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
  236.     {
  237.       register int key = hash (str, len);
  238.  
  239.       if (key <= MAX_HASH_VALUE && key >= 0)
  240.         {
  241.           register char *s = wordlist[key].name;
  242.  
  243.           if (*s == *str && !strcmp (str + 1, s + 1))
  244.             return &wordlist[key];
  245.         }
  246.     }
  247.   return 0;
  248. }
  249.