aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/hash.h
blob: fceaa63ccfc6e28f6528816d3c698087802425e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/* C code produced by gperf version 2.5 (GNU C++ version) */
/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,7,$ ../../../devo/gcc/cp/gxx.gperf  */
/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$,7 gplus.gperf  */
struct resword { char *name; short token; enum rid rid;};

#define TOTAL_KEYWORDS 86
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 13
#define MIN_HASH_VALUE 4
#define MAX_HASH_VALUE 196
/* maximum key range = 193, duplicates = 0 */

#ifdef __GNUC__
inline
#endif
static unsigned int
hash (str, len)
     register char *str;
     register int unsigned len;
{
  static unsigned char asso_values[] =
    {
     197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
     197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
     197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
     197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
     197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
     197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
     197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
     197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
     197, 197, 197, 197, 197, 197, 197, 197, 197, 197,
     197, 197, 197, 197, 197,   0, 197,  93,   3,  35,
       3,   0,  71,   8,   4,  78, 197,   3,  30,   6,
      29,  18,  37, 197,  55,   0,   4,  11,   7,  20,
       0,   8, 197, 197, 197, 197, 197, 197,
    };
  register int hval = len;

  switch (hval)
    {
      default:
      case 7:
        hval += asso_values[str[6]];
      case 6:
      case 5:
      case 4:
        hval += asso_values[str[3]];
      case 3:
      case 2:
      case 1:
        hval += asso_values[str[0]];
    }
  return hval + asso_values[str[len - 1]];
}

#ifdef __GNUC__
inline
#endif
struct resword *
is_reserved_word (str, len)
     register char *str;
     register unsigned int len;
{
  static struct resword wordlist[] =
    {
      {"",}, {"",}, {"",}, {"",}, 
      {"else",  ELSE, NORID,},
      {"",}, {"",}, 
      {"__asm__",  GCC_ASM_KEYWORD, NORID},
      {"this",  THIS, NORID,},
      {"delete",  DELETE, NORID,},
      {"except",  EXCEPT, NORID		/* Extension */,},
      {"__asm",  GCC_ASM_KEYWORD, NORID},
      {"double",  TYPESPEC, RID_DOUBLE,},
      {"typeid",  TYPEID, NORID,},
      {"switch",  SWITCH, NORID,},
      {"try",  TRY, NORID			/* Extension */,},
      {"enum",  ENUM, NORID,},
      {"void",  TYPESPEC, RID_VOID,},
      {"",}, {"",}, {"",}, 
      {"struct",  AGGR, RID_RECORD,},
      {"",}, 
      {"do",  DO, NORID,},
      {"",}, {"",}, {"",}, {"",}, 
      {"__headof__",  HEADOF, NORID},
      {"",}, {"",}, 
      {"__const__",  TYPE_QUAL, RID_CONST},
      {"__volatile",  TYPE_QUAL, RID_VOLATILE},
      {"__const",  TYPE_QUAL, RID_CONST},
      {"__volatile__",  TYPE_QUAL, RID_VOLATILE},
      {"extern",  SCSPEC, RID_EXTERN,},
      {"__typeof__",  TYPEOF, NORID},
      {"",}, 
      {"signed",  TYPESPEC, RID_SIGNED,},
      {"case",  CASE, NORID,},
      {"class",  AGGR, RID_CLASS,},
      {"__classof__",  CLASSOF, NORID},
      {"__extension__",  EXTENSION, NORID},
      {"",}, 
      {"const",  TYPE_QUAL, RID_CONST,},
      {"static",  SCSPEC, RID_STATIC,},
      {"",}, 
      {"throw",  THROW, NORID		/* Extension */,},
      {"goto",  GOTO, NORID,},
      {"signature",  AGGR, RID_SIGNATURE	/* Extension */,},
      {"long",  TYPESPEC, RID_LONG,},
      {"private",  VISSPEC, RID_PRIVATE,},
      {"new",  NEW, NORID,},
      {"template",  TEMPLATE, NORID,},
      {"",}, 
      {"while",  WHILE, NORID,},
      {"",}, 
      {"protected",  VISSPEC, RID_PROTECTED,},
      {"continue",  CONTINUE, NORID,},
      {"",}, 
      {"raise",  RAISE, NORID		/* Extension */,},
      {"raises",  RAISES, NORID		/* Extension */,},
      {"",}, 
      {"union",  AGGR, RID_UNION,},
      {"short",  TYPESPEC, RID_SHORT,},
      {"",}, 
      {"__inline",  SCSPEC, RID_INLINE},
      {"",}, 
      {"__inline__",  SCSPEC, RID_INLINE},
      {"",}, 
      {"__alignof__",  ALIGNOF, NORID},
      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"sizeof",  SIZEOF, NORID,},
      {"virtual",  SCSPEC, RID_VIRTUAL,},
      {"catch",  CATCH, NORID,},
      {"friend",  SCSPEC, RID_FRIEND,},
      {"typeof",  TYPEOF, NORID,},
      {"",}, {"",}, 
      {"headof",  HEADOF, NORID,},
      {"int",  TYPESPEC, RID_INT,},
      {"",}, {"",}, 
      {"__signed__",  TYPESPEC, RID_SIGNED},
      {"__signed",  TYPESPEC, RID_SIGNED},
      {"",}, {"",}, {"",}, 
      {"__attribute",  ATTRIBUTE, NORID},
      {"sigof",  SIGOF, NORID		/* Extension */,},
      {"__attribute__",  ATTRIBUTE, NORID},
      {"",}, 
      {"__headof",  HEADOF, NORID},
      {"",}, {"",}, 
      {"unsigned",  TYPESPEC, RID_UNSIGNED,},
      {"return",  RETURN, NORID,},
      {"asm",  ASM_KEYWORD, NORID,},
      {"__wchar_t",  TYPESPEC, RID_WCHAR  /* Unique to ANSI C++ */,},
      {"break",  BREAK, NORID,},
      {"__typeof",  TYPEOF, NORID},
      {"mutable",  SCSPEC, RID_MUTABLE,},
      {"",}, 
      {"public",  VISSPEC, RID_PUBLIC,},
      {"",}, 
      {"__classof",  CLASSOF, NORID},
      {"default",  DEFAULT, NORID,},
      {"",}, {"",}, {"",}, {"",}, 
      {"exception",  AGGR, RID_EXCEPTION	/* Extension */,},
      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"all",  ALL, NORID			/* Extension */,},
      {"",}, {"",}, 
      {"for",  FOR, NORID,},
      {"",}, {"",}, 
      {"__label__",  LABEL, NORID},
      {"auto",  SCSPEC, RID_AUTO,},
      {"",}, {"",}, {"",}, {"",}, 
      {"volatile",  TYPE_QUAL, RID_VOLATILE,},
      {"__alignof",  ALIGNOF, NORID},
      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"dynamic_cast",  DYNAMIC_CAST, NORID,},
      {"",}, 
      {"char",  TYPESPEC, RID_CHAR,},
      {"",}, 
      {"if",  IF, NORID,},
      {"",}, 
      {"typedef",  SCSPEC, RID_TYPEDEF,},
      {"operator",  OPERATOR, NORID,},
      {"reraise",  RERAISE, NORID		/* Extension */,},
      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"inline",  SCSPEC, RID_INLINE,},
      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"",}, 
      {"float",  TYPESPEC, RID_FLOAT,},
      {"",}, {"",}, {"",}, 
      {"overload",  OVERLOAD, NORID,},
      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"classof",  CLASSOF, NORID,},
      {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 
      {"",}, {"",}, 
      {"register",  SCSPEC, RID_REGISTER,},
    };

  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      register int key = hash (str, len);

      if (key <= MAX_HASH_VALUE && key >= 0)
        {
          register char *s = wordlist[key].name;

          if (*s == *str && !strcmp (str + 1, s + 1))
            return &wordlist[key];
        }
    }
  return 0;
}