GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
oct-gperf.h
Go to the documentation of this file.
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-2024 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  arguments_kw,
67  break_kw,
68  case_kw,
69  catch_kw,
70  classdef_kw,
71  continue_kw,
72  do_kw,
73  else_kw,
74  elseif_kw,
75  end_kw,
76  end_try_catch_kw,
77  end_unwind_protect_kw,
78  endarguments_kw,
79  endclassdef_kw,
80  endenumeration_kw,
81  endevents_kw,
82  endfor_kw,
83  endfunction_kw,
84  endif_kw,
85  endmethods_kw,
86  endparfor_kw,
87  endproperties_kw,
88  endspmd_kw,
89  endswitch_kw,
90  endwhile_kw,
91  enumeration_kw,
92  events_kw,
93  for_kw,
94  function_kw,
95  get_kw,
96  global_kw,
97  if_kw,
98  magic_file_kw,
99  magic_line_kw,
100  methods_kw,
101  otherwise_kw,
102  parfor_kw,
103  persistent_kw,
104  properties_kw,
105  return_kw,
106  set_kw,
107  spmd_kw,
108  switch_kw,
109  try_kw,
110  until_kw,
111  unwind_protect_kw,
112  unwind_protect_cleanup_kw,
113  while_kw
114 };
115 
116 #line 86 "../libinterp/parse-tree/octave.gperf"
117 struct octave_kw { const char *name; int tok; octave_kw_id kw_id; };
118 
119 #define TOTAL_KEYWORDS 48
120 #define MIN_WORD_LENGTH 2
121 #define MAX_WORD_LENGTH 22
122 #define MIN_HASH_VALUE 2
123 #define MAX_HASH_VALUE 71
124 /* maximum key range = 70, duplicates = 0 */
125 
126 class octave_kw_hash
127 {
128 private:
129  static inline unsigned int hash (const char *str, size_t len);
130 public:
131  static const struct octave_kw *in_word_set (const char *str, size_t len);
132 };
133 
134 inline unsigned int
135 octave_kw_hash::hash (const char *str, size_t len)
136 {
137  static const unsigned char asso_values[] =
138  {
139  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
140  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
141  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
142  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
143  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
144  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
145  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
146  72, 72, 72, 72, 72, 72, 55, 72, 5, 72,
147  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
148  72, 72, 72, 72, 72, 5, 72, 25, 0, 10,
149  0, 0, 30, 40, 50, 30, 72, 0, 30, 5,
150  10, 10, 10, 72, 0, 5, 25, 35, 35, 20,
151  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
152  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
153  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
154  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
155  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
156  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
157  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
158  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
159  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
160  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
161  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
162  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
163  72, 72, 72, 72, 72, 72, 72, 72, 72, 72,
164  72, 72, 72, 72, 72, 72
165  };
166  unsigned int hval = len;
167 
168  switch (hval)
169  {
170  default:
171  hval += asso_values[static_cast<unsigned char>(str[4])];
172  /*FALLTHROUGH*/
173  case 4:
174  case 3:
175  case 2:
176  case 1:
177  hval += asso_values[static_cast<unsigned char>(str[0])];
178  break;
179  }
180  return hval;
181 }
182 
183 static const struct octave_kw wordlist[] =
184  {
185 #line 95 "../libinterp/parse-tree/octave.gperf"
186  {"do", DO, do_kw},
187 #line 98 "../libinterp/parse-tree/octave.gperf"
188  {"end", END, end_kw},
189 #line 96 "../libinterp/parse-tree/octave.gperf"
190  {"else", ELSE, else_kw},
191 #line 90 "../libinterp/parse-tree/octave.gperf"
192  {"break", BREAK, break_kw},
193 #line 126 "../libinterp/parse-tree/octave.gperf"
194  {"return", FUNC_RET, return_kw},
195 #line 127 "../libinterp/parse-tree/octave.gperf"
196  {"set", SET, set_kw},
197 #line 128 "../libinterp/parse-tree/octave.gperf"
198  {"spmd", SPMD, spmd_kw},
199 #line 108 "../libinterp/parse-tree/octave.gperf"
200  {"endmethods", END, endmethods_kw},
201 #line 114 "../libinterp/parse-tree/octave.gperf"
202  {"enumeration", ENUMERATION, enumeration_kw},
203 #line 101 "../libinterp/parse-tree/octave.gperf"
204  {"endarguments", END, endarguments_kw},
205 #line 110 "../libinterp/parse-tree/octave.gperf"
206  {"endproperties", END, endproperties_kw},
207 #line 91 "../libinterp/parse-tree/octave.gperf"
208  {"case", CASE, case_kw},
209 #line 105 "../libinterp/parse-tree/octave.gperf"
210  {"endfor", END, endfor_kw},
211 #line 111 "../libinterp/parse-tree/octave.gperf"
212  {"endspmd", END, endspmd_kw},
213 #line 136 "../libinterp/parse-tree/octave.gperf"
214  {"__LINE__", NUMBER, magic_line_kw},
215 #line 122 "../libinterp/parse-tree/octave.gperf"
216  {"otherwise", OTHERWISE, otherwise_kw},
217 #line 125 "../libinterp/parse-tree/octave.gperf"
218  {"properties", PROPERTIES, properties_kw},
219 #line 129 "../libinterp/parse-tree/octave.gperf"
220  {"switch", SWITCH, switch_kw},
221 #line 121 "../libinterp/parse-tree/octave.gperf"
222  {"methods", METHODS, methods_kw},
223 #line 93 "../libinterp/parse-tree/octave.gperf"
224  {"classdef", CLASSDEF, classdef_kw},
225 #line 103 "../libinterp/parse-tree/octave.gperf"
226  {"endenumeration", END, endenumeration_kw},
227 #line 134 "../libinterp/parse-tree/octave.gperf"
228  {"while", WHILE, while_kw},
229 #line 123 "../libinterp/parse-tree/octave.gperf"
230  {"parfor", PARFOR, parfor_kw},
231 #line 130 "../libinterp/parse-tree/octave.gperf"
232  {"try", TRY, try_kw},
233 #line 112 "../libinterp/parse-tree/octave.gperf"
234  {"endswitch", END, endswitch_kw},
235 #line 115 "../libinterp/parse-tree/octave.gperf"
236  {"events", EVENTS, events_kw},
237 #line 120 "../libinterp/parse-tree/octave.gperf"
238  {"if", IF, if_kw},
239 #line 116 "../libinterp/parse-tree/octave.gperf"
240  {"for", FOR, for_kw},
241 #line 109 "../libinterp/parse-tree/octave.gperf"
242  {"endparfor", END, endparfor_kw},
243 #line 107 "../libinterp/parse-tree/octave.gperf"
244  {"endif", END, endif_kw},
245 #line 97 "../libinterp/parse-tree/octave.gperf"
246  {"elseif", ELSEIF, elseif_kw},
247 #line 99 "../libinterp/parse-tree/octave.gperf"
248  {"end_try_catch", END, end_try_catch_kw},
249 #line 89 "../libinterp/parse-tree/octave.gperf"
250  {"arguments", ARGUMENTS, arguments_kw},
251 #line 102 "../libinterp/parse-tree/octave.gperf"
252  {"endclassdef", END, endclassdef_kw},
253 #line 118 "../libinterp/parse-tree/octave.gperf"
254  {"get", GET, get_kw},
255 #line 104 "../libinterp/parse-tree/octave.gperf"
256  {"endevents", END, endevents_kw},
257 #line 106 "../libinterp/parse-tree/octave.gperf"
258  {"endfunction", END, endfunction_kw},
259 #line 94 "../libinterp/parse-tree/octave.gperf"
260  {"continue", CONTINUE, continue_kw},
261 #line 124 "../libinterp/parse-tree/octave.gperf"
262  {"persistent", PERSISTENT, persistent_kw},
263 #line 100 "../libinterp/parse-tree/octave.gperf"
264  {"end_unwind_protect", END, end_unwind_protect_kw},
265 #line 113 "../libinterp/parse-tree/octave.gperf"
266  {"endwhile", END, endwhile_kw},
267 #line 132 "../libinterp/parse-tree/octave.gperf"
268  {"unwind_protect", UNWIND, unwind_protect_kw},
269 #line 117 "../libinterp/parse-tree/octave.gperf"
270  {"function", FCN, function_kw},
271 #line 92 "../libinterp/parse-tree/octave.gperf"
272  {"catch", CATCH, catch_kw},
273 #line 133 "../libinterp/parse-tree/octave.gperf"
274  {"unwind_protect_cleanup", CLEANUP, unwind_protect_cleanup_kw},
275 #line 135 "../libinterp/parse-tree/octave.gperf"
276  {"__FILE__", DQ_STRING, magic_file_kw},
277 #line 131 "../libinterp/parse-tree/octave.gperf"
278  {"until", UNTIL, until_kw},
279 #line 119 "../libinterp/parse-tree/octave.gperf"
280  {"global", GLOBAL, global_kw}
281  };
282 
283 static const signed char gperf_lookup[] =
284  {
285  -1, -1, 0, 1, 2, 3, 4, -1, 5, 6, 7, 8, 9, 10,
286  11, -1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, -1,
287  23, 24, -1, 25, 26, 27, 28, 29, 30, -1, 31, 32, -1, 33,
288  -1, 34, 35, -1, 36, -1, 37, -1, 38, -1, -1, 39, -1, -1,
289  -1, -1, 40, 41, -1, -1, -1, 42, -1, 43, -1, 44, 45, -1,
290  46, 47
291  };
292 
293 const struct octave_kw *
294 octave_kw_hash::in_word_set (const char *str, size_t len)
295 {
296  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
297  {
298  unsigned int key = hash (str, len);
299 
300  if (key <= MAX_HASH_VALUE)
301  {
302  int index = gperf_lookup[key];
303 
304  if (index >= 0)
305  {
306  const char *s = wordlist[index].name;
307 
308  if (*str == *s && !strcmp (str + 1, s + 1))
309  return &wordlist[index];
310  }
311  }
312  }
313  return 0;
314 }