Ruby: lex.c Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

lex.c
1/* ANSI-C code produced by gperf version 3.1 */
2/* Command-line: gperf -C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' defs/keywords */
3
4#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
5 && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
6 && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
7 && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
8 && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
9 && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
10 && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
11 && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
12 && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
13 && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
14 && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
15 && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
16 && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
17 && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
18 && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
19 && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
20 && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
21 && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
22 && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
23 && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
24 && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
25 && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
26 && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
27/* The character set is not based on ISO-646. */
28#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
29#endif
30
31#define gperf_offsetof(s, n) (short)offsetof(struct s##_t, s##_str##n)
32#line 1 "defs/keywords"
33
34 struct kwtable {short name, id[2], state;};
35const struct kwtable *rb_reserved_word(const char *, unsigned int);
36#ifndef RIPPER
37static const struct kwtable *reserved_word(register const char *str, register size_t len);
38#define rb_reserved_word(str, len) reserved_word(str, len)
39#line 9 "defs/keywords"
40struct kwtable;
41
42#define TOTAL_KEYWORDS 41
43#define MIN_WORD_LENGTH 2
44#define MAX_WORD_LENGTH 12
45#define MIN_HASH_VALUE 8
46#define MAX_HASH_VALUE 50
47/* maximum key range = 43, duplicates = 0 */
48
49#ifdef __GNUC__
50__inline
51#else
52#ifdef __cplusplus
53inline
54#endif
55#endif
56static unsigned int
57hash (register const char *str, register size_t len)
58{
59 static const unsigned char asso_values[] =
60 {
61 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
62 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
63 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
64 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
65 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
66 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
67 51, 51, 51, 26, 51, 51, 14, 51, 16, 8,
68 11, 13, 51, 51, 51, 51, 10, 51, 13, 51,
69 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
70 51, 51, 51, 51, 51, 11, 51, 13, 1, 26,
71 4, 1, 8, 28, 51, 23, 51, 1, 1, 27,
72 5, 19, 21, 51, 8, 3, 3, 11, 51, 21,
73 24, 16, 51, 51, 51, 51, 51, 51, 51, 51,
74 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
75 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
76 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
77 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
78 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
79 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
80 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
81 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
82 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
83 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
84 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
85 51, 51, 51, 51, 51, 51, 51, 51, 51, 51,
86 51, 51, 51, 51, 51, 51
87 };
88 register unsigned int hval = (unsigned int)len;
89
90 switch (hval)
91 {
92 default:
93 hval += asso_values[(unsigned char)str[2]];
94 /*FALLTHROUGH*/
95 case 2:
96 case 1:
97 hval += asso_values[(unsigned char)str[0]];
98 break;
99 }
100 return (unsigned int)hval + asso_values[(unsigned char)str[len - 1]];
101}
102
103 struct stringpool_t
104 {
105 char stringpool_str8[sizeof("break")];
106 char stringpool_str9[sizeof("else")];
107 char stringpool_str10[sizeof("nil")];
108 char stringpool_str11[sizeof("ensure")];
109 char stringpool_str12[sizeof("end")];
110 char stringpool_str13[sizeof("then")];
111 char stringpool_str14[sizeof("not")];
112 char stringpool_str15[sizeof("false")];
113 char stringpool_str16[sizeof("self")];
114 char stringpool_str17[sizeof("elsif")];
115 char stringpool_str18[sizeof("rescue")];
116 char stringpool_str19[sizeof("true")];
117 char stringpool_str20[sizeof("until")];
118 char stringpool_str21[sizeof("unless")];
119 char stringpool_str22[sizeof("return")];
120 char stringpool_str23[sizeof("def")];
121 char stringpool_str24[sizeof("and")];
122 char stringpool_str25[sizeof("do")];
123 char stringpool_str26[sizeof("yield")];
124 char stringpool_str27[sizeof("for")];
125 char stringpool_str28[sizeof("undef")];
126 char stringpool_str29[sizeof("or")];
127 char stringpool_str30[sizeof("in")];
128 char stringpool_str31[sizeof("when")];
129 char stringpool_str32[sizeof("retry")];
130 char stringpool_str33[sizeof("if")];
131 char stringpool_str34[sizeof("case")];
132 char stringpool_str35[sizeof("redo")];
133 char stringpool_str36[sizeof("next")];
134 char stringpool_str37[sizeof("super")];
135 char stringpool_str38[sizeof("module")];
136 char stringpool_str39[sizeof("begin")];
137 char stringpool_str40[sizeof("__LINE__")];
138 char stringpool_str41[sizeof("__FILE__")];
139 char stringpool_str42[sizeof("__ENCODING__")];
140 char stringpool_str43[sizeof("END")];
141 char stringpool_str44[sizeof("alias")];
142 char stringpool_str45[sizeof("BEGIN")];
143 char stringpool_str46[sizeof("defined?")];
144 char stringpool_str47[sizeof("class")];
145 char stringpool_str50[sizeof("while")];
146 };
147static const struct stringpool_t stringpool_contents =
148 {
149 "break",
150 "else",
151 "nil",
152 "ensure",
153 "end",
154 "then",
155 "not",
156 "false",
157 "self",
158 "elsif",
159 "rescue",
160 "true",
161 "until",
162 "unless",
163 "return",
164 "def",
165 "and",
166 "do",
167 "yield",
168 "for",
169 "undef",
170 "or",
171 "in",
172 "when",
173 "retry",
174 "if",
175 "case",
176 "redo",
177 "next",
178 "super",
179 "module",
180 "begin",
181 "__LINE__",
182 "__FILE__",
183 "__ENCODING__",
184 "END",
185 "alias",
186 "BEGIN",
187 "defined?",
188 "class",
189 "while"
190 };
191#define stringpool ((const char *) &stringpool_contents)
192const struct kwtable *
193rb_reserved_word (register const char *str, register size_t len)
194{
195 static const struct kwtable wordlist[] =
196 {
197 {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1},
198#line 19 "defs/keywords"
199 {gperf_offsetof(stringpool, 8), {keyword_break, keyword_break}, EXPR_MID},
200#line 25 "defs/keywords"
201 {gperf_offsetof(stringpool, 9), {keyword_else, keyword_else}, EXPR_BEG},
202#line 35 "defs/keywords"
203 {gperf_offsetof(stringpool, 10), {keyword_nil, keyword_nil}, EXPR_END},
204#line 28 "defs/keywords"
205 {gperf_offsetof(stringpool, 11), {keyword_ensure, keyword_ensure}, EXPR_BEG},
206#line 27 "defs/keywords"
207 {gperf_offsetof(stringpool, 12), {keyword_end, keyword_end}, EXPR_END},
208#line 44 "defs/keywords"
209 {gperf_offsetof(stringpool, 13), {keyword_then, keyword_then}, EXPR_BEG},
210#line 36 "defs/keywords"
211 {gperf_offsetof(stringpool, 14), {keyword_not, keyword_not}, EXPR_ARG},
212#line 29 "defs/keywords"
213 {gperf_offsetof(stringpool, 15), {keyword_false, keyword_false}, EXPR_END},
214#line 42 "defs/keywords"
215 {gperf_offsetof(stringpool, 16), {keyword_self, keyword_self}, EXPR_END},
216#line 26 "defs/keywords"
217 {gperf_offsetof(stringpool, 17), {keyword_elsif, keyword_elsif}, EXPR_VALUE},
218#line 39 "defs/keywords"
219 {gperf_offsetof(stringpool, 18), {keyword_rescue, modifier_rescue}, EXPR_MID},
220#line 45 "defs/keywords"
221 {gperf_offsetof(stringpool, 19), {keyword_true, keyword_true}, EXPR_END},
222#line 48 "defs/keywords"
223 {gperf_offsetof(stringpool, 20), {keyword_until, modifier_until}, EXPR_VALUE},
224#line 47 "defs/keywords"
225 {gperf_offsetof(stringpool, 21), {keyword_unless, modifier_unless}, EXPR_VALUE},
226#line 41 "defs/keywords"
227 {gperf_offsetof(stringpool, 22), {keyword_return, keyword_return}, EXPR_MID},
228#line 22 "defs/keywords"
229 {gperf_offsetof(stringpool, 23), {keyword_def, keyword_def}, EXPR_FNAME},
230#line 17 "defs/keywords"
231 {gperf_offsetof(stringpool, 24), {keyword_and, keyword_and}, EXPR_VALUE},
232#line 24 "defs/keywords"
233 {gperf_offsetof(stringpool, 25), {keyword_do, keyword_do}, EXPR_BEG},
234#line 51 "defs/keywords"
235 {gperf_offsetof(stringpool, 26), {keyword_yield, keyword_yield}, EXPR_ARG},
236#line 30 "defs/keywords"
237 {gperf_offsetof(stringpool, 27), {keyword_for, keyword_for}, EXPR_VALUE},
238#line 46 "defs/keywords"
239 {gperf_offsetof(stringpool, 28), {keyword_undef, keyword_undef}, EXPR_FNAME|EXPR_FITEM},
240#line 37 "defs/keywords"
241 {gperf_offsetof(stringpool, 29), {keyword_or, keyword_or}, EXPR_VALUE},
242#line 32 "defs/keywords"
243 {gperf_offsetof(stringpool, 30), {keyword_in, keyword_in}, EXPR_VALUE},
244#line 49 "defs/keywords"
245 {gperf_offsetof(stringpool, 31), {keyword_when, keyword_when}, EXPR_VALUE},
246#line 40 "defs/keywords"
247 {gperf_offsetof(stringpool, 32), {keyword_retry, keyword_retry}, EXPR_END},
248#line 31 "defs/keywords"
249 {gperf_offsetof(stringpool, 33), {keyword_if, modifier_if}, EXPR_VALUE},
250#line 20 "defs/keywords"
251 {gperf_offsetof(stringpool, 34), {keyword_case, keyword_case}, EXPR_VALUE},
252#line 38 "defs/keywords"
253 {gperf_offsetof(stringpool, 35), {keyword_redo, keyword_redo}, EXPR_END},
254#line 34 "defs/keywords"
255 {gperf_offsetof(stringpool, 36), {keyword_next, keyword_next}, EXPR_MID},
256#line 43 "defs/keywords"
257 {gperf_offsetof(stringpool, 37), {keyword_super, keyword_super}, EXPR_ARG},
258#line 33 "defs/keywords"
259 {gperf_offsetof(stringpool, 38), {keyword_module, keyword_module}, EXPR_VALUE},
260#line 18 "defs/keywords"
261 {gperf_offsetof(stringpool, 39), {keyword_begin, keyword_begin}, EXPR_BEG},
262#line 12 "defs/keywords"
263 {gperf_offsetof(stringpool, 40), {keyword__LINE__, keyword__LINE__}, EXPR_END},
264#line 13 "defs/keywords"
265 {gperf_offsetof(stringpool, 41), {keyword__FILE__, keyword__FILE__}, EXPR_END},
266#line 11 "defs/keywords"
267 {gperf_offsetof(stringpool, 42), {keyword__ENCODING__, keyword__ENCODING__}, EXPR_END},
268#line 15 "defs/keywords"
269 {gperf_offsetof(stringpool, 43), {keyword_END, keyword_END}, EXPR_END},
270#line 16 "defs/keywords"
271 {gperf_offsetof(stringpool, 44), {keyword_alias, keyword_alias}, EXPR_FNAME|EXPR_FITEM},
272#line 14 "defs/keywords"
273 {gperf_offsetof(stringpool, 45), {keyword_BEGIN, keyword_BEGIN}, EXPR_END},
274#line 23 "defs/keywords"
275 {gperf_offsetof(stringpool, 46), {keyword_defined, keyword_defined}, EXPR_ARG},
276#line 21 "defs/keywords"
277 {gperf_offsetof(stringpool, 47), {keyword_class, keyword_class}, EXPR_CLASS},
278 {-1}, {-1},
279#line 50 "defs/keywords"
280 {gperf_offsetof(stringpool, 50), {keyword_while, modifier_while}, EXPR_VALUE}
281 };
282
283 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
284 {
285 register unsigned int key = hash (str, len);
286
287 if (key <= MAX_HASH_VALUE)
288 {
289 register int o = wordlist[key].name;
290 if (o >= 0)
291 {
292 register const char *s = o + stringpool;
293
294 if (*str == *s && !strcmp (str + 1, s + 1))
295 return &wordlist[key];
296 }
297 }
298 }
299 return 0;
300}
301#line 52 "defs/keywords"
302
303#endif