Initial import from FreeBSD RELENG_4:
[games.git] / contrib / gperf / tests / test-4.exp
1 /* C code produced by gperf version 2.7 */
2 /* Command-line: ../src/gperf -D -p -t  */
3 /* Command-line: gperf -p -j1 -i 1 -g -o -t -N is_reserved_word -k1,3,$ c-parse.gperf  */
4 struct resword { char *name; short token; enum rid rid; };
5
6 #define TOTAL_KEYWORDS 51
7 #define MIN_WORD_LENGTH 2
8 #define MAX_WORD_LENGTH 13
9 #define MIN_HASH_VALUE 4
10 #define MAX_HASH_VALUE 82
11 /* maximum key range = 79, duplicates = 2 */
12
13 #ifdef __GNUC__
14 __inline
15 #endif
16 static unsigned int
17 hash (str, len)
18      register const char *str;
19      register unsigned int len;
20 {
21   static unsigned char asso_values[] =
22     {
23       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
24       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
25       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
26       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
27       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
28       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
29       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
30       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
31       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
32       83, 83, 83, 83, 83,  0, 83, 40, 20, 50,
33       25, 10, 30,  0,  0, 50, 83,  0, 15,  0,
34       35,  0, 83, 83, 20,  0, 10, 40,  5, 15,
35       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
36       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
37       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
38       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
39       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
40       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
41       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
42       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
43       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
44       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
45       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
46       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
47       83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
48       83, 83, 83, 83, 83, 83
49     };
50   return len + asso_values[(unsigned char)str[len - 1]] + asso_values[(unsigned char)str[0]];
51 }
52
53 #ifdef __GNUC__
54 __inline
55 #endif
56 struct resword *
57 in_word_set (str, len)
58      register const char *str;
59      register unsigned int len;
60 {
61   static struct resword wordlist[] =
62     {
63       {"goto", GOTO, NORID},
64       {"__asm", ASM, NORID},
65       {"switch", SWITCH, NORID},
66       {"__asm__", ASM, NORID},
67       {"__const__", TYPE_QUAL, RID_CONST},
68       {"__inline__", SCSPEC, RID_INLINE},
69       {"__typeof__", TYPEOF, NORID},
70       {"__signed__", TYPESPEC, RID_SIGNED},
71       {"__alignof__", ALIGNOF, NORID},
72       {"__volatile__", TYPE_QUAL, RID_VOLATILE},
73       {"__attribute__", ATTRIBUTE, NORID},
74       {"enum", ENUM, NORID},
75       {"short", TYPESPEC, RID_SHORT},
76       {"struct", STRUCT, NORID},
77       {"__const", TYPE_QUAL, RID_CONST},
78       {"__inline", SCSPEC, RID_INLINE},
79       {"long", TYPESPEC, RID_LONG},
80       {"__volatile", TYPE_QUAL, RID_VOLATILE},
81       {"__attribute", ATTRIBUTE, NORID},
82       {"volatile", TYPE_QUAL, RID_VOLATILE},
83       {"else", ELSE, NORID},
84       {"break", BREAK, NORID},
85       {"do", DO, NORID},
86       {"while", WHILE, NORID},
87       {"signed", TYPESPEC, RID_SIGNED},
88       {"__signed", TYPESPEC, RID_SIGNED},
89       {"void", TYPESPEC, RID_VOID},
90       {"sizeof", SIZEOF, NORID},
91       {"__typeof", TYPEOF, NORID},
92       {"__alignof", ALIGNOF, NORID},
93       {"double", TYPESPEC, RID_DOUBLE},
94       {"default", DEFAULT, NORID},
95       {"asm", ASM, NORID},
96       {"auto", SCSPEC, RID_AUTO},
97       {"float", TYPESPEC, RID_FLOAT},
98       {"typeof", TYPEOF, NORID},
99       {"typedef", SCSPEC, RID_TYPEDEF},
100       {"register", SCSPEC, RID_REGISTER},
101       {"extern", SCSPEC, RID_EXTERN},
102       {"for", FOR, NORID},
103       {"static", SCSPEC, RID_STATIC},
104       {"return", RETURN, NORID},
105       {"int", TYPESPEC, RID_INT},
106       {"case", CASE, NORID},
107       {"const", TYPE_QUAL, RID_CONST},
108       {"inline", SCSPEC, RID_INLINE},
109       {"continue", CONTINUE, NORID},
110       {"unsigned", TYPESPEC, RID_UNSIGNED},
111       {"char", TYPESPEC, RID_CHAR},
112       {"union", UNION, NORID},
113       {"if", IF, NORID}
114     };
115
116   static short lookup[] =
117     {
118        -1,  -1,  -1,  -1,   0,   1,   2,   3,  -1,   4,
119       -80,   8,   9,  10,  11,  12,  13,  14,  15,  16,
120        17,  18,  -1,  19,  20,  21,  -1,  22, -46,  -3,
121        23,  24,  -1,  25,  26,  -1,  27,  -1,  28,  29,
122        -1,  30,  31,  32,  33,  34,  35,  36,  37,  -1,
123        -1,  38,  -1,  39,  -1,  -1,  40,  -1,  -1,  -1,
124        -1,  41,  -1,  42,  43,  44,  45,  -1,  46,  -1,
125        -1,  -1,  -1,  47,  48,  -1,  -1,  -1,  -1,  -1,
126        49,  -1,  50
127     };
128
129   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
130     {
131       register int key = hash (str, len);
132
133       if (key <= MAX_HASH_VALUE && key >= 0)
134         {
135           register int index = lookup[key];
136
137           if (index >= 0)
138             {
139               register const char *s = wordlist[index].name;
140
141               if (*str == *s && !strcmp (str + 1, s + 1))
142                 return &wordlist[index];
143             }
144           else if (index < -TOTAL_KEYWORDS)
145             {
146               register int offset = - 1 - TOTAL_KEYWORDS - index;
147               register struct resword *wordptr = &wordlist[TOTAL_KEYWORDS + lookup[offset]];
148               register struct resword *wordendptr = wordptr + -lookup[offset + 1];
149
150               while (wordptr < wordendptr)
151                 {
152                   register const char *s = wordptr->name;
153
154                   if (*str == *s && !strcmp (str + 1, s + 1))
155                     return wordptr;
156                   wordptr++;
157                 }
158             }
159         }
160     }
161   return 0;
162 }