GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
oct-gperf.h
Go to the documentation of this file.
1 /* C++ code produced by gperf version 3.0.4 */
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-gnu-gperf@gnu.org>."
30 #endif
31 
32 #line 1 "../libinterp/parse-tree/octave.gperf"
33 
34 /*
35 
36 Copyright (C) 1995-2017 John W. Eaton
37 
38 This file is part of Octave.
39 
40 Octave is free software; you can redistribute it and/or modify it
41 under the terms of the GNU General Public License as published by the
42 Free Software Foundation; either version 3 of the License, or (at
43 your option) any later version.
44 
45 Octave is distributed in the hope that it will be useful, but WITHOUT
46 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
47 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
48 for more details.
49 
50 You should have received a copy of the GNU General Public License
51 along with Octave; see the file COPYING. If not, see
52 <http://www.gnu.org/licenses/>.
53 
54 NOTE: gperf 2.7.2 will silently generate bad code if there are blank
55 lines following the "%{" marker above. This comment block seems to be
56 handled correctly.
57 
58 */
60 {
105 };
106 #line 75 "../libinterp/parse-tree/octave.gperf"
107 struct octave_kw { const char *name; int tok; octave_kw_id kw_id; };
108 
109 #define TOTAL_KEYWORDS 44
110 #define MIN_WORD_LENGTH 2
111 #define MAX_WORD_LENGTH 22
112 #define MIN_HASH_VALUE 2
113 #define MAX_HASH_VALUE 68
114 /* maximum key range = 67, duplicates = 0 */
115 
117 {
118 private:
119  static inline unsigned int hash (const char *str, unsigned int len);
120 public:
121  static const struct octave_kw *in_word_set (const char *str, unsigned int len);
122 };
123 
124 inline unsigned int
125 octave_kw_hash::hash (const char *str, unsigned int len)
126 {
127  static const unsigned char asso_values[] =
128  {
129  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
130  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
131  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
132  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
133  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
134  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
135  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
136  69, 69, 69, 69, 69, 69, 55, 69, 5, 69,
137  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
138  69, 69, 69, 69, 69, 5, 69, 50, 0, 5,
139  0, 0, 45, 5, 50, 15, 69, 0, 25, 0,
140  0, 20, 5, 69, 25, 30, 10, 35, 10, 15,
141  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
142  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
143  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
144  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
145  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
146  69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
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
155  };
156  int hval = len;
157 
158  switch (hval)
159  {
160  default:
161  hval += asso_values[(unsigned char)str[4]];
162  /*FALLTHROUGH*/
163  case 4:
164  case 3:
165  case 2:
166  case 1:
167  hval += asso_values[(unsigned char)str[0]];
168  break;
169  }
170  return hval;
171 }
172 
173 static const struct octave_kw wordlist[] =
174  {
175 #line 82 "../libinterp/parse-tree/octave.gperf"
176  {"do", DO, do_kw},
177 #line 85 "../libinterp/parse-tree/octave.gperf"
178  {"end", END, end_kw},
179 #line 83 "../libinterp/parse-tree/octave.gperf"
180  {"else", ELSE, else_kw},
181 #line 77 "../libinterp/parse-tree/octave.gperf"
182  {"break", BREAK, break_kw},
183 #line 103 "../libinterp/parse-tree/octave.gperf"
184  {"get", GET, get_kw},
185 #line 78 "../libinterp/parse-tree/octave.gperf"
186  {"case", CASE, case_kw},
187 #line 94 "../libinterp/parse-tree/octave.gperf"
188  {"endmethods", END, endmethods_kw},
189 #line 99 "../libinterp/parse-tree/octave.gperf"
190  {"enumeration", ENUMERATION, enumeration_kw},
191 #line 114 "../libinterp/parse-tree/octave.gperf"
192  {"try", TRY, try_kw},
193 #line 89 "../libinterp/parse-tree/octave.gperf"
194  {"endenumeration", END, endenumeration_kw},
195 #line 110 "../libinterp/parse-tree/octave.gperf"
196  {"properties", PROPERTIES, properties_kw},
197 #line 100 "../libinterp/parse-tree/octave.gperf"
198  {"events", EVENTS, events_kw},
199 #line 105 "../libinterp/parse-tree/octave.gperf"
200  {"if", IF, if_kw},
201 #line 120 "../libinterp/parse-tree/octave.gperf"
202  {"__LINE__", NUM, magic_line_kw},
203 #line 90 "../libinterp/parse-tree/octave.gperf"
204  {"endevents", END, endevents_kw},
205 #line 118 "../libinterp/parse-tree/octave.gperf"
206  {"while", WHILE, while_kw},
207 #line 84 "../libinterp/parse-tree/octave.gperf"
208  {"elseif", ELSEIF, elseif_kw},
209 #line 86 "../libinterp/parse-tree/octave.gperf"
210  {"end_try_catch", END, end_try_catch_kw},
211 #line 97 "../libinterp/parse-tree/octave.gperf"
212  {"endswitch", END, endswitch_kw},
213 #line 91 "../libinterp/parse-tree/octave.gperf"
214  {"endfor", END, endfor_kw},
215 #line 106 "../libinterp/parse-tree/octave.gperf"
216  {"methods", METHODS, methods_kw},
217 #line 81 "../libinterp/parse-tree/octave.gperf"
218  {"continue", CONTINUE, continue_kw},
219 #line 109 "../libinterp/parse-tree/octave.gperf"
220  {"persistent", PERSISTENT, persistent_kw},
221 #line 108 "../libinterp/parse-tree/octave.gperf"
222  {"parfor", PARFOR, parfor_kw},
223 #line 112 "../libinterp/parse-tree/octave.gperf"
224  {"set", SET, set_kw},
225 #line 88 "../libinterp/parse-tree/octave.gperf"
226  {"endclassdef", END, endclassdef_kw},
227 #line 96 "../libinterp/parse-tree/octave.gperf"
228  {"endproperties", END, endproperties_kw},
229 #line 113 "../libinterp/parse-tree/octave.gperf"
230  {"switch", SWITCH, switch_kw},
231 #line 80 "../libinterp/parse-tree/octave.gperf"
232  {"classdef", CLASSDEF, classdef_kw},
233 #line 92 "../libinterp/parse-tree/octave.gperf"
234  {"endfunction", END, endfunction_kw},
235 #line 101 "../libinterp/parse-tree/octave.gperf"
236  {"for", FOR, for_kw},
237 #line 116 "../libinterp/parse-tree/octave.gperf"
238  {"unwind_protect", UNWIND, unwind_protect_kw},
239 #line 93 "../libinterp/parse-tree/octave.gperf"
240  {"endif", END, endif_kw},
241 #line 87 "../libinterp/parse-tree/octave.gperf"
242  {"end_unwind_protect", END, end_unwind_protect_kw},
243 #line 107 "../libinterp/parse-tree/octave.gperf"
244  {"otherwise", OTHERWISE, otherwise_kw},
245 #line 111 "../libinterp/parse-tree/octave.gperf"
246  {"return", FUNC_RET, return_kw},
247 #line 117 "../libinterp/parse-tree/octave.gperf"
248  {"unwind_protect_cleanup", CLEANUP, unwind_protect_cleanup_kw},
249 #line 98 "../libinterp/parse-tree/octave.gperf"
250  {"endwhile", END, endwhile_kw},
251 #line 95 "../libinterp/parse-tree/octave.gperf"
252  {"endparfor", END, endparfor_kw},
253 #line 79 "../libinterp/parse-tree/octave.gperf"
254  {"catch", CATCH, catch_kw},
255 #line 104 "../libinterp/parse-tree/octave.gperf"
256  {"global", GLOBAL, global_kw},
257 #line 102 "../libinterp/parse-tree/octave.gperf"
258  {"function", FCN, function_kw},
259 #line 115 "../libinterp/parse-tree/octave.gperf"
260  {"until", UNTIL, until_kw},
261 #line 119 "../libinterp/parse-tree/octave.gperf"
262  {"__FILE__", DQ_STRING, magic_file_kw}
263  };
264 
265 static const signed char gperf_lookup[] =
266  {
267  -1, -1, 0, 1, 2, 3, -1, -1, 4, 5, 6, 7, -1, 8,
268  9, 10, 11, 12, 13, 14, 15, 16, -1, 17, 18, -1, 19, 20,
269  21, -1, 22, 23, -1, 24, -1, -1, 25, -1, 26, -1, -1, 27,
270  -1, 28, -1, -1, 29, -1, 30, 31, 32, -1, -1, 33, 34, -1,
271  35, 36, 37, 38, 39, 40, -1, 41, -1, 42, -1, -1, 43
272  };
273 
274 const struct octave_kw *
275 octave_kw_hash::in_word_set (const char *str, unsigned int len)
276 {
277  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
278  {
279  int key = hash (str, len);
280 
281  if (key <= MAX_HASH_VALUE && key >= 0)
282  {
283  int index = gperf_lookup[key];
284 
285  if (index >= 0)
286  {
287  const char *s = wordlist[index].name;
288 
289  if (*str == *s && !strcmp (str + 1, s + 1))
290  return &wordlist[index];
291  }
292  }
293  }
294  return 0;
295 }
Definition: oct-parse.h:103
Definition: oct-parse.h:129
static const struct octave_kw wordlist[]
Definition: oct-gperf.h:173
Definition: oct-parse.h:98
static const struct octave_kw * in_word_set(const char *str, unsigned int len)
Definition: oct-gperf.h:275
s
Definition: file-io.cc:2682
octave_kw_id
Definition: oct-gperf.h:59
octave_kw_id kw_id
Definition: oct-gperf.h:107
#define END
Definition: oct-parse.h:114
#define PERSISTENT
Definition: oct-parse.cc:349
bool strcmp(const T &str_a, const T &str_b)
True if strings are the same.
Definition: oct-string.cc:112
std::string str
Definition: hash.cc:118
#define NUM
Definition: oct-parse.h:127
Definition: oct-parse.h:101
static const signed char gperf_lookup[]
Definition: oct-gperf.h:265
#define MIN_WORD_LENGTH
Definition: oct-gperf.h:110
const char * name
Definition: oct-gperf.h:107
Definition: oct-parse.h:128
static unsigned int hash(const char *str, unsigned int len)
Definition: oct-gperf.h:125