File: oct-gperf.h

package info (click to toggle)
octave 6.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 124,192 kB
  • sloc: cpp: 322,665; ansic: 68,088; fortran: 20,980; objc: 8,121; sh: 7,719; yacc: 4,266; lex: 4,123; perl: 1,530; java: 1,366; awk: 1,257; makefile: 424; xml: 147
file content (301 lines) | stat: -rw-r--r-- 10,671 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
/* C++ code produced by gperf version 3.1 */
/* Command-line: gperf -t -C -D -G -L C++ -Z octave_kw_hash ../libinterp/parse-tree/octave.gperf  */
/* Computed positions: -k'1,5' */

#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
      && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
      && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
      && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
      && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
      && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
      && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
      && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
      && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
      && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
      && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
      && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
      && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
      && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
      && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
      && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
      && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
      && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
      && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
      && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
      && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
      && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
      && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646.  */
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif

#line 1 "../libinterp/parse-tree/octave.gperf"


////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 1995-2021 The Octave Project Developers
//
// See the file COPYRIGHT.md in the top-level directory of this
// distribution or <https://octave.org/copyright/>.
//
// This file is part of Octave.
//
// Octave is free software: you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Octave is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Octave; see the file COPYING.  If not, see
// <https://www.gnu.org/licenses/>.
//
// NOTE: gperf 2.7.2 will silently generate bad code if there are blank
// lines following the "%{" marker above.  This comment block seems to be
// handled correctly.
//
////////////////////////////////////////////////////////////////////////

enum octave_kw_id
{
  break_kw,
  case_kw,
  catch_kw,
  classdef_kw,
  continue_kw,
  do_kw,
  else_kw,
  elseif_kw,
  end_kw,
  end_try_catch_kw,
  end_unwind_protect_kw,
  endclassdef_kw,
  endenumeration_kw,
  endevents_kw,
  endfor_kw,
  endfunction_kw,
  endif_kw,
  endmethods_kw,
  endparfor_kw,
  endproperties_kw,
  endswitch_kw,
  endwhile_kw,
  enumeration_kw,
  events_kw,
  for_kw,
  function_kw,
  get_kw,
  global_kw,
  if_kw,
  magic_file_kw,
  magic_line_kw,
  methods_kw,
  otherwise_kw,
  parfor_kw,
  persistent_kw,
  properties_kw,
  return_kw,
  set_kw,
  switch_kw,
  try_kw,
  until_kw,
  unwind_protect_kw,
  unwind_protect_cleanup_kw,
  while_kw
};

#line 82 "../libinterp/parse-tree/octave.gperf"
struct octave_kw { const char *name; int tok; octave_kw_id kw_id; };

#define TOTAL_KEYWORDS 44
#define MIN_WORD_LENGTH 2
#define MAX_WORD_LENGTH 22
#define MIN_HASH_VALUE 2
#define MAX_HASH_VALUE 68
/* maximum key range = 67, duplicates = 0 */

class octave_kw_hash
{
private:
  static inline unsigned int hash (const char *str, size_t len);
public:
  static const struct octave_kw *in_word_set (const char *str, size_t len);
};

inline unsigned int
octave_kw_hash::hash (const char *str, size_t len)
{
  static const unsigned char asso_values[] =
    {
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 55, 69,  5, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69,  5, 69, 50,  0,  5,
       0,  0, 45,  5, 50, 15, 69,  0, 25,  0,
       0, 20,  5, 69, 25, 30, 10, 35, 10, 15,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
      69, 69, 69, 69, 69, 69
    };
  unsigned int hval = len;

  switch (hval)
    {
      default:
        hval += asso_values[static_cast<unsigned char>(str[4])];
      /*FALLTHROUGH*/
      case 4:
      case 3:
      case 2:
      case 1:
        hval += asso_values[static_cast<unsigned char>(str[0])];
        break;
    }
  return hval;
}

static const struct octave_kw wordlist[] =
  {
#line 90 "../libinterp/parse-tree/octave.gperf"
    {"do", DO, do_kw},
#line 93 "../libinterp/parse-tree/octave.gperf"
    {"end", END, end_kw},
#line 91 "../libinterp/parse-tree/octave.gperf"
    {"else", ELSE, else_kw},
#line 85 "../libinterp/parse-tree/octave.gperf"
    {"break", BREAK, break_kw},
#line 111 "../libinterp/parse-tree/octave.gperf"
    {"get", GET, get_kw},
#line 86 "../libinterp/parse-tree/octave.gperf"
    {"case", CASE, case_kw},
#line 102 "../libinterp/parse-tree/octave.gperf"
    {"endmethods", END, endmethods_kw},
#line 107 "../libinterp/parse-tree/octave.gperf"
    {"enumeration", ENUMERATION, enumeration_kw},
#line 122 "../libinterp/parse-tree/octave.gperf"
    {"try", TRY, try_kw},
#line 97 "../libinterp/parse-tree/octave.gperf"
    {"endenumeration", END, endenumeration_kw},
#line 118 "../libinterp/parse-tree/octave.gperf"
    {"properties", PROPERTIES, properties_kw},
#line 108 "../libinterp/parse-tree/octave.gperf"
    {"events", EVENTS, events_kw},
#line 113 "../libinterp/parse-tree/octave.gperf"
    {"if", IF, if_kw},
#line 128 "../libinterp/parse-tree/octave.gperf"
    {"__LINE__", NUM, magic_line_kw},
#line 98 "../libinterp/parse-tree/octave.gperf"
    {"endevents", END, endevents_kw},
#line 126 "../libinterp/parse-tree/octave.gperf"
    {"while", WHILE, while_kw},
#line 92 "../libinterp/parse-tree/octave.gperf"
    {"elseif", ELSEIF, elseif_kw},
#line 94 "../libinterp/parse-tree/octave.gperf"
    {"end_try_catch", END, end_try_catch_kw},
#line 105 "../libinterp/parse-tree/octave.gperf"
    {"endswitch", END, endswitch_kw},
#line 99 "../libinterp/parse-tree/octave.gperf"
    {"endfor", END, endfor_kw},
#line 114 "../libinterp/parse-tree/octave.gperf"
    {"methods", METHODS, methods_kw},
#line 89 "../libinterp/parse-tree/octave.gperf"
    {"continue", CONTINUE, continue_kw},
#line 117 "../libinterp/parse-tree/octave.gperf"
    {"persistent", PERSISTENT, persistent_kw},
#line 116 "../libinterp/parse-tree/octave.gperf"
    {"parfor", PARFOR, parfor_kw},
#line 120 "../libinterp/parse-tree/octave.gperf"
    {"set", SET, set_kw},
#line 96 "../libinterp/parse-tree/octave.gperf"
    {"endclassdef", END, endclassdef_kw},
#line 104 "../libinterp/parse-tree/octave.gperf"
    {"endproperties", END, endproperties_kw},
#line 121 "../libinterp/parse-tree/octave.gperf"
    {"switch", SWITCH, switch_kw},
#line 88 "../libinterp/parse-tree/octave.gperf"
    {"classdef", CLASSDEF, classdef_kw},
#line 100 "../libinterp/parse-tree/octave.gperf"
    {"endfunction", END, endfunction_kw},
#line 109 "../libinterp/parse-tree/octave.gperf"
    {"for", FOR, for_kw},
#line 124 "../libinterp/parse-tree/octave.gperf"
    {"unwind_protect", UNWIND, unwind_protect_kw},
#line 101 "../libinterp/parse-tree/octave.gperf"
    {"endif", END, endif_kw},
#line 95 "../libinterp/parse-tree/octave.gperf"
    {"end_unwind_protect", END, end_unwind_protect_kw},
#line 115 "../libinterp/parse-tree/octave.gperf"
    {"otherwise", OTHERWISE, otherwise_kw},
#line 119 "../libinterp/parse-tree/octave.gperf"
    {"return", FUNC_RET, return_kw},
#line 125 "../libinterp/parse-tree/octave.gperf"
    {"unwind_protect_cleanup", CLEANUP, unwind_protect_cleanup_kw},
#line 106 "../libinterp/parse-tree/octave.gperf"
    {"endwhile", END, endwhile_kw},
#line 103 "../libinterp/parse-tree/octave.gperf"
    {"endparfor", END, endparfor_kw},
#line 87 "../libinterp/parse-tree/octave.gperf"
    {"catch", CATCH, catch_kw},
#line 112 "../libinterp/parse-tree/octave.gperf"
    {"global", GLOBAL, global_kw},
#line 110 "../libinterp/parse-tree/octave.gperf"
    {"function", FCN, function_kw},
#line 123 "../libinterp/parse-tree/octave.gperf"
    {"until", UNTIL, until_kw},
#line 127 "../libinterp/parse-tree/octave.gperf"
    {"__FILE__", DQ_STRING, magic_file_kw}
  };

static const signed char gperf_lookup[] =
  {
    -1, -1,  0,  1,  2,  3, -1, -1,  4,  5,  6,  7, -1,  8,
     9, 10, 11, 12, 13, 14, 15, 16, -1, 17, 18, -1, 19, 20,
    21, -1, 22, 23, -1, 24, -1, -1, 25, -1, 26, -1, -1, 27,
    -1, 28, -1, -1, 29, -1, 30, 31, 32, -1, -1, 33, 34, -1,
    35, 36, 37, 38, 39, 40, -1, 41, -1, 42, -1, -1, 43
  };

const struct octave_kw *
octave_kw_hash::in_word_set (const char *str, size_t len)
{
  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
    {
      unsigned int key = hash (str, len);

      if (key <= MAX_HASH_VALUE)
        {
          int index = gperf_lookup[key];

          if (index >= 0)
            {
              const char *s = wordlist[index].name;

              if (*str == *s && !strcmp (str + 1, s + 1))
                return &wordlist[index];
            }
        }
    }
  return 0;
}