1 /* C++ code produced by gperf version 3.1 */
2 /* Command-line: gperf -t -C -D -G -L C++ -Z octave_kw_hash ../libinterp/parse-tree/octave.gperf  */
3 /* Computed positions: -k'1,5' */
4 
5 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
6       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
7       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
8       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
9       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
10       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
11       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
12       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
13       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
14       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
15       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
16       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
17       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
18       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
19       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
20       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
21       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
22       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
23       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
24       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
25       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
26       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
27       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
28 /* The character set is not based on ISO-646.  */
29 #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
30 #endif
31 
32 #line 1 "../libinterp/parse-tree/octave.gperf"
33 
34 
35 ////////////////////////////////////////////////////////////////////////
36 //
37 // Copyright (C) 1995-2021 The Octave Project Developers
38 //
39 // See the file COPYRIGHT.md in the top-level directory of this
40 // distribution or <https://octave.org/copyright/>.
41 //
42 // This file is part of Octave.
43 //
44 // Octave is free software: you can redistribute it and/or modify it
45 // under the terms of the GNU General Public License as published by
46 // the Free Software Foundation, either version 3 of the License, or
47 // (at your option) any later version.
48 //
49 // Octave is distributed in the hope that it will be useful, but
50 // WITHOUT ANY WARRANTY; without even the implied warranty of
51 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
52 // GNU General Public License for more details.
53 //
54 // You should have received a copy of the GNU General Public License
55 // along with Octave; see the file COPYING.  If not, see
56 // <https://www.gnu.org/licenses/>.
57 //
58 // NOTE: gperf 2.7.2 will silently generate bad code if there are blank
59 // lines following the "%{" marker above.  This comment block seems to be
60 // handled correctly.
61 //
62 ////////////////////////////////////////////////////////////////////////
63 
64 enum octave_kw_id
65 {
66   break_kw,
67   case_kw,
68   catch_kw,
69   classdef_kw,
70   continue_kw,
71   do_kw,
72   else_kw,
73   elseif_kw,
74   end_kw,
75   end_try_catch_kw,
76   end_unwind_protect_kw,
77   endclassdef_kw,
78   endenumeration_kw,
79   endevents_kw,
80   endfor_kw,
81   endfunction_kw,
82   endif_kw,
83   endmethods_kw,
84   endparfor_kw,
85   endproperties_kw,
86   endswitch_kw,
87   endwhile_kw,
88   enumeration_kw,
89   events_kw,
90   for_kw,
91   function_kw,
92   get_kw,
93   global_kw,
94   if_kw,
95   magic_file_kw,
96   magic_line_kw,
97   methods_kw,
98   otherwise_kw,
99   parfor_kw,
100   persistent_kw,
101   properties_kw,
102   return_kw,
103   set_kw,
104   switch_kw,
105   try_kw,
106   until_kw,
107   unwind_protect_kw,
108   unwind_protect_cleanup_kw,
109   while_kw
110 };
111 
112 #line 82 "../libinterp/parse-tree/octave.gperf"
113 struct octave_kw { const char *name; int tok; octave_kw_id kw_id; };
114 
115 #define TOTAL_KEYWORDS 44
116 #define MIN_WORD_LENGTH 2
117 #define MAX_WORD_LENGTH 22
118 #define MIN_HASH_VALUE 2
119 #define MAX_HASH_VALUE 68
120 /* maximum key range = 67, duplicates = 0 */
121 
122 class octave_kw_hash
123 {
124 private:
125   static inline unsigned int hash (const char *str, size_t len);
126 public:
127   static const struct octave_kw *in_word_set (const char *str, size_t len);
128 };
129 
130 inline unsigned int
hash(const char * str,size_t len)131 octave_kw_hash::hash (const char *str, size_t len)
132 {
133   static const unsigned char asso_values[] =
134     {
135       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
136       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
137       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
138       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
139       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
140       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
141       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
142       69, 69, 69, 69, 69, 69, 55, 69,  5, 69,
143       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
144       69, 69, 69, 69, 69,  5, 69, 50,  0,  5,
145        0,  0, 45,  5, 50, 15, 69,  0, 25,  0,
146        0, 20,  5, 69, 25, 30, 10, 35, 10, 15,
147       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
148       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
149       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
150       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
151       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
152       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
153       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
154       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
155       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
156       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
157       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
158       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
159       69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
160       69, 69, 69, 69, 69, 69
161     };
162   unsigned int hval = len;
163 
164   switch (hval)
165     {
166       default:
167         hval += asso_values[static_cast<unsigned char>(str[4])];
168       /*FALLTHROUGH*/
169       case 4:
170       case 3:
171       case 2:
172       case 1:
173         hval += asso_values[static_cast<unsigned char>(str[0])];
174         break;
175     }
176   return hval;
177 }
178 
179 static const struct octave_kw wordlist[] =
180   {
181 #line 90 "../libinterp/parse-tree/octave.gperf"
182     {"do", DO, do_kw},
183 #line 93 "../libinterp/parse-tree/octave.gperf"
184     {"end", END, end_kw},
185 #line 91 "../libinterp/parse-tree/octave.gperf"
186     {"else", ELSE, else_kw},
187 #line 85 "../libinterp/parse-tree/octave.gperf"
188     {"break", BREAK, break_kw},
189 #line 111 "../libinterp/parse-tree/octave.gperf"
190     {"get", GET, get_kw},
191 #line 86 "../libinterp/parse-tree/octave.gperf"
192     {"case", CASE, case_kw},
193 #line 102 "../libinterp/parse-tree/octave.gperf"
194     {"endmethods", END, endmethods_kw},
195 #line 107 "../libinterp/parse-tree/octave.gperf"
196     {"enumeration", ENUMERATION, enumeration_kw},
197 #line 122 "../libinterp/parse-tree/octave.gperf"
198     {"try", TRY, try_kw},
199 #line 97 "../libinterp/parse-tree/octave.gperf"
200     {"endenumeration", END, endenumeration_kw},
201 #line 118 "../libinterp/parse-tree/octave.gperf"
202     {"properties", PROPERTIES, properties_kw},
203 #line 108 "../libinterp/parse-tree/octave.gperf"
204     {"events", EVENTS, events_kw},
205 #line 113 "../libinterp/parse-tree/octave.gperf"
206     {"if", IF, if_kw},
207 #line 128 "../libinterp/parse-tree/octave.gperf"
208     {"__LINE__", NUM, magic_line_kw},
209 #line 98 "../libinterp/parse-tree/octave.gperf"
210     {"endevents", END, endevents_kw},
211 #line 126 "../libinterp/parse-tree/octave.gperf"
212     {"while", WHILE, while_kw},
213 #line 92 "../libinterp/parse-tree/octave.gperf"
214     {"elseif", ELSEIF, elseif_kw},
215 #line 94 "../libinterp/parse-tree/octave.gperf"
216     {"end_try_catch", END, end_try_catch_kw},
217 #line 105 "../libinterp/parse-tree/octave.gperf"
218     {"endswitch", END, endswitch_kw},
219 #line 99 "../libinterp/parse-tree/octave.gperf"
220     {"endfor", END, endfor_kw},
221 #line 114 "../libinterp/parse-tree/octave.gperf"
222     {"methods", METHODS, methods_kw},
223 #line 89 "../libinterp/parse-tree/octave.gperf"
224     {"continue", CONTINUE, continue_kw},
225 #line 117 "../libinterp/parse-tree/octave.gperf"
226     {"persistent", PERSISTENT, persistent_kw},
227 #line 116 "../libinterp/parse-tree/octave.gperf"
228     {"parfor", PARFOR, parfor_kw},
229 #line 120 "../libinterp/parse-tree/octave.gperf"
230     {"set", SET, set_kw},
231 #line 96 "../libinterp/parse-tree/octave.gperf"
232     {"endclassdef", END, endclassdef_kw},
233 #line 104 "../libinterp/parse-tree/octave.gperf"
234     {"endproperties", END, endproperties_kw},
235 #line 121 "../libinterp/parse-tree/octave.gperf"
236     {"switch", SWITCH, switch_kw},
237 #line 88 "../libinterp/parse-tree/octave.gperf"
238     {"classdef", CLASSDEF, classdef_kw},
239 #line 100 "../libinterp/parse-tree/octave.gperf"
240     {"endfunction", END, endfunction_kw},
241 #line 109 "../libinterp/parse-tree/octave.gperf"
242     {"for", FOR, for_kw},
243 #line 124 "../libinterp/parse-tree/octave.gperf"
244     {"unwind_protect", UNWIND, unwind_protect_kw},
245 #line 101 "../libinterp/parse-tree/octave.gperf"
246     {"endif", END, endif_kw},
247 #line 95 "../libinterp/parse-tree/octave.gperf"
248     {"end_unwind_protect", END, end_unwind_protect_kw},
249 #line 115 "../libinterp/parse-tree/octave.gperf"
250     {"otherwise", OTHERWISE, otherwise_kw},
251 #line 119 "../libinterp/parse-tree/octave.gperf"
252     {"return", FUNC_RET, return_kw},
253 #line 125 "../libinterp/parse-tree/octave.gperf"
254     {"unwind_protect_cleanup", CLEANUP, unwind_protect_cleanup_kw},
255 #line 106 "../libinterp/parse-tree/octave.gperf"
256     {"endwhile", END, endwhile_kw},
257 #line 103 "../libinterp/parse-tree/octave.gperf"
258     {"endparfor", END, endparfor_kw},
259 #line 87 "../libinterp/parse-tree/octave.gperf"
260     {"catch", CATCH, catch_kw},
261 #line 112 "../libinterp/parse-tree/octave.gperf"
262     {"global", GLOBAL, global_kw},
263 #line 110 "../libinterp/parse-tree/octave.gperf"
264     {"function", FCN, function_kw},
265 #line 123 "../libinterp/parse-tree/octave.gperf"
266     {"until", UNTIL, until_kw},
267 #line 127 "../libinterp/parse-tree/octave.gperf"
268     {"__FILE__", DQ_STRING, magic_file_kw}
269   };
270 
271 static const signed char gperf_lookup[] =
272   {
273     -1, -1,  0,  1,  2,  3, -1, -1,  4,  5,  6,  7, -1,  8,
274      9, 10, 11, 12, 13, 14, 15, 16, -1, 17, 18, -1, 19, 20,
275     21, -1, 22, 23, -1, 24, -1, -1, 25, -1, 26, -1, -1, 27,
276     -1, 28, -1, -1, 29, -1, 30, 31, 32, -1, -1, 33, 34, -1,
277     35, 36, 37, 38, 39, 40, -1, 41, -1, 42, -1, -1, 43
278   };
279 
280 const struct octave_kw *
in_word_set(const char * str,size_t len)281 octave_kw_hash::in_word_set (const char *str, size_t len)
282 {
283   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
284     {
285       unsigned int key = hash (str, len);
286 
287       if (key <= MAX_HASH_VALUE)
288         {
289           int index = gperf_lookup[key];
290 
291           if (index >= 0)
292             {
293               const char *s = wordlist[index].name;
294 
295               if (*str == *s && !strcmp (str + 1, s + 1))
296                 return &wordlist[index];
297             }
298         }
299     }
300   return 0;
301 }
302