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