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();
39 _Bool, (T_BOOL & 0x7f)
40 _Complex, (T_COMPLEX & 0x7f)
41 _Imaginary, (T_IMAGINARY & 0x7f)
44 const, (T_CONST & 0x7f)
45 double, (T_DOUBLE & 0x7f)
47 extern, (T_EXTERN & 0x7f)
48 float, (T_FLOAT & 0x7f)
49 inline, (T_INLINE & 0x7f)
52 register, (T_REGISTER & 0x7f)
53 restrict, (T_RESTRICT & 0x7f)
54 short, (T_SHORT & 0x7f)
55 signed, (T_SIGNED & 0x7f)
56 static, (T_STATIC & 0x7f)
57 struct, (T_STRUCT & 0x7f)
58 typedef, (T_TYPEDEF & 0x7f)
59 union, (T_UNION & 0x7f)
60 unsigned, (T_UNSIGNED & 0x7f)
62 volatile, (T_VOLATILE & 0x7f)
64 array, (T_ARRAY & 0x7f) | 0x80
65 as, (T_AS & 0x7f) | 0x80
66 declare, (T_DECLARE & 0x7f) | 0x80
67 function, (T_FUNCTION & 0x7f) | 0x80
68 of, (T_OF & 0x7f) | 0x80
69 pointer, (T_POINTER & 0x7f) | 0x80
70 returning, (T_RETURNING & 0x7f) | 0x80
71 to, (T_TO & 0x7f) | 0x80
72 type, (T_TYPE & 0x7f) | 0x80
73 variable-length, (T_VLA & 0x7f) | 0x80
75 int cdecl__to_keyword(const char *s, int len, int english_mode)
77 const struct keyword *k;
79 if ((k = in_word_set(s, len))) {
80 unsigned x = (k->token & 0x7fu);
82 if (english_mode || !(k->token & ~0x7fu)) {