3 * Copyright © 2023 Nick Bowler
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 #include "cdecl-internal.h"
25 static const struct keyword *in_word_set();
31 /* Note: the following options enable gperf-wordwrap.awk to do its thing */
32 %define word-array-name wordlist_wrapped
40 _Bool, (T_BOOL & 0x7f)
41 _Complex, (T_COMPLEX & 0x7f)
42 _Imaginary, (T_IMAGINARY & 0x7f)
45 const, (T_CONST & 0x7f)
46 double, (T_DOUBLE & 0x7f)
48 extern, (T_EXTERN & 0x7f)
49 float, (T_FLOAT & 0x7f)
50 inline, (T_INLINE & 0x7f)
53 register, (T_REGISTER & 0x7f)
54 restrict, (T_RESTRICT & 0x7f)
55 short, (T_SHORT & 0x7f)
56 signed, (T_SIGNED & 0x7f)
57 static, (T_STATIC & 0x7f)
58 struct, (T_STRUCT & 0x7f)
59 typedef, (T_TYPEDEF & 0x7f)
60 union, (T_UNION & 0x7f)
61 unsigned, (T_UNSIGNED & 0x7f)
63 volatile, (T_VOLATILE & 0x7f)
65 array, (T_ARRAY & 0x7f) | 0x80
66 as, (T_AS & 0x7f) | 0x80
67 declare, (T_DECLARE & 0x7f) | 0x80
68 function, (T_FUNCTION & 0x7f) | 0x80
69 of, (T_OF & 0x7f) | 0x80
70 pointer, (T_POINTER & 0x7f) | 0x80
71 returning, (T_RETURNING & 0x7f) | 0x80
72 to, (T_TO & 0x7f) | 0x80
73 type, (T_TYPE & 0x7f) | 0x80
74 variable-length, (T_VLA & 0x7f) | 0x80
76 int cdecl__to_keyword(const char *s, int len, int english_mode)
78 const struct keyword *k;
80 if ((k = in_word_set(s, len))) {
81 unsigned x = (k->token & 0x7fu);
83 if (english_mode || !(k->token & ~0x7fu)) {
93 static const char *wordlist_func(const struct keyword *k)
95 unsigned x = k->token & 0x7f;
103 return cdecl__token_name(x);