1 /*
2 **      cdecl -- C gibberish translator
3 **      src/literals.h
4 **
5 **      Copyright (C) 2017-2021  Paul J. Lucas
6 **
7 **      This program is free software: you can redistribute it and/or modify
8 **      it under the terms of the GNU General Public License as published by
9 **      the Free Software Foundation, either version 3 of the License, or
10 **      (at your option) any later version.
11 **
12 **      This program is distributed in the hope that it will be useful,
13 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
14 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 **      GNU General Public License for more details.
16 **
17 **      You should have received a copy of the GNU General Public License
18 **      along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef cdecl_literals_H
22 #define cdecl_literals_H
23 
24 /**
25  * @file
26  * Declares constants for cdecl and C/C++ language literals.
27  */
28 
29 // local
30 #include "pjl_config.h"                 /* must go first */
31 #include "c_lang.h"
32 
33 /// @cond DOXYGEN_IGNORE
34 
35 _GL_INLINE_HEADER_BEGIN
36 #ifndef C_LITERALS_INLINE
37 # define C_LITERALS_INLINE _GL_INLINE
38 #endif /* C_LITERALS_INLINE */
39 
40 /// @endcond
41 
42 /**
43  * @defgroup literals-group Literal Strings
44  * Declares constants for cdecl and C/C++ language literals.
45  * @{
46  */
47 
48 ////////// literals ///////////////////////////////////////////////////////////
49 
50 // A literal starting with "H_" is pseudo-English for the same literal starting
51 // with "L_" and are spelled the same except that '-' replaces '_' ("H_" for
52 // "hyphen").
53 
54 // If you add a new literal and it is:
55 //
56 //  + A cdecl command only, update CDECL_KEYWORDS in lexer.l and
57 //    AC_CDECL_COMMANDS in autocomplete.c (if you want it auto-completable).
58 //
59 //  + A cdecl command that is also a C/C++ keyword -OR- a C/C++ keyword only,
60 //    update C_KEYWORDS in c_keywords.c.
61 
62 // english
63 extern char const L_ALIGN[];
64 extern char const L_ALIGNED[];
65 extern char const L_ALL[];
66 extern char const L_ARRAY[];
67 extern char const L_AS[];
68 extern char const L_BITS[];
69 extern char const L_BYTES[];
70 extern char const L_CAST[];
71 extern char const L_COMMAND[];            // synonym for "commands"
72 extern char const L_COMMANDS[];
73 extern char const L_DECLARE[];
74 extern char const L_DEFAULTED[];          // synonym for "default"
75 extern char const L_DEFINE[];
76 extern char const L_DELETED[];            // synonym for "delete"
77 extern char const L_ENGLISH[];
78 extern char const L_EVAL[];               // synonym for "evaluation"
79 extern char const L_EVALUATION[];
80 extern char const L_EXIT[];
81 extern char const L_EXPLAIN[];
82 extern char const L_EXPR[];               // synonym for "expression"
83 extern char const L_EXPRESSION[];
84 extern char const L_FUNC[];               // synonym for "function"
85 extern char const L_FUNCTION[];
86 extern char const L_HELP[];
87 extern char const L_INIT[];               // synonym for "initialization"
88 extern char const L_INITIALIZATION[];
89 extern char const L_INTO[];
90 extern char const L_LINKAGE[];
91 extern char const L_MBR[];                // synonym for "member"
92 extern char const L_MEMBER[];
93 extern char const L_NO[];
94 extern char const H_NON_MBR[];            // synonym for "non-member"
95 extern char const H_NON_MEMBER[];
96 extern char const L_OF[];
97 extern char const L_OPTIONS[];
98 extern char const L_POINTER[];
99 extern char const L_PREDEF[];             // synonym for "predefined"
100 extern char const L_PREDEFINED[];
101 extern char const L_PTR[];                // synonym for "pointer"
102 extern char const L_Q[];                  // synonym for "quit"
103 extern char const L_QUIT[];
104 extern char const L_REF[];                // synonym for "reference"
105 extern char const L_REFERENCE[];
106 extern char const L_RET[];                // synonym for "returning"
107 extern char const L_RETURNING[];
108 extern char const L_RVALUE[];
109 extern char const L_SET_COMMAND[];        // L_SET is synonym for SEEK_SET
110 extern char const L_SHOW[];
111 extern char const L_TO[];
112 extern char const L_USER[];
113 extern char const L_VECTOR[];             // synonym for "array"
114 extern char const L_WIDTH[];
115 
116 // K&R
117 extern char const L_AUTO[];
118 extern char const L_AUTOMATIC[];          // synonym for "auto", "__auto_type"
119 extern char const L_BREAK[];
120 extern char const L_CASE[];
121 extern char const L_CHAR[];
122 extern char const L_CHARACTER[];          // English for "char"
123 extern char const L_CONTINUE[];
124 extern char const L_DEFAULT[];
125 extern char const L_DO[];
126 extern char const L_DOUBLE[];
127 extern char const H_DOUBLE_PRECISION[];   // English for "double"
128 extern char const L_ELSE[];
129 extern char const L_EXTERN[];
130 extern char const L_EXTERNAL[];           // English for "extern"
131 extern char const L_FLOAT[];
132 extern char const H_FLOATING_POINT[];     // English for "float"
133 extern char const L_FOR[];
134 extern char const L_GOTO[];
135 extern char const L_IF[];
136 extern char const L_INT[];
137 extern char const L_INTEGER[];            // English for "int"
138 extern char const L_LONG[];
139 extern char const L_REGISTER[];
140 extern char const L_RETURN[];
141 extern char const L_SHORT[];
142 extern char const L_SIZEOF[];
143 extern char const L_STATIC[];
144 extern char const L_STRUCT[];
145 extern char const L_STRUCTURE[];          // English for "struct"
146 extern char const L_SWITCH[];
147 extern char const L_TYPE[];               // English for "typedef"
148 extern char const L_TYPEDEF[];
149 extern char const L_UNION[];
150 extern char const L_UNSIGNED[];
151 extern char const L_WHILE[];
152 
153 // C89
154 extern char const L_ASM[];
155 extern char const L_CONST[];
156 extern char const L_CONSTANT[];           // English for "const"
157 extern char const L_ELLIPSIS[];           // ...
158 extern char const L_ENUM[];
159 extern char const L_ENUMERATION[];        // English for "enum"
160 extern char const L_SIGNED[];
161 extern char const L_VARARGS[];            // synonym for "..."
162 extern char const L_VARIADIC[];           // synonym for "..."
163 extern char const L_VOID[];
164 extern char const L_VOLATILE[];
165 
166 // C99
167 extern char const L__BOOL[];
168 extern char const L__COMPLEX[];
169 extern char const L_COMPLEX[];            // synonym for "_Complex"
170 extern char const L__IMAGINARY[];
171 extern char const L_IMAGINARY[];          // synonym for "_Imaginary"
172 extern char const L_INLINE[];
173 extern char const L_LEN[];                // synonym for "length"
174 extern char const L_LENGTH[];             // for "variable [length] array"
175 extern char const L_RESTRICT[];
176 extern char const L_RESTRICTED[];         // synonym for "restrict"
177 extern char const L_VAR[];                // synonym for "variable"
178 extern char const L_VARIABLE[];           // for "variable [length] array"
179 extern char const L_WCHAR_T[];
180 
181 // C11
182 extern char const L__ALIGNAS[];
183 extern char const L__ALIGNOF[];
184 extern char const L__ATOMIC[];
185 extern char const L_ATOMIC[];             // synonym for "_Atomic"
186 extern char const L__GENERIC[];
187 extern char const L__NORETURN[];
188 extern char const H_NO_RETURN[];          // English for "_Noreturn"
189 extern char const H_NON_RETURNING[];      // English for "_Noreturn"
190 extern char const L__STATIC_ASSERT[];
191 extern char const L__THREAD_LOCAL[];
192 extern char const L_THREAD[], L_LOCAL[];
193 extern char const H_THREAD_LOCAL[];       // English for "_Thread_local"
194 
195 // C++
196 extern char const L_BOOL[];
197 extern char const L_CATCH[];
198 extern char const L_CLASS[];
199 extern char const L_CONSTRUCTOR[];
200 extern char const L_CONST_CAST[];
201 extern char const L_CONV[];               // synonym for "conversion"
202 extern char const L_CONVERSION[];
203 extern char const L_CTOR[];               // synonym for "constructor"
204 extern char const L_DELETE[];
205 extern char const L_DESTRUCTOR[];
206 extern char const L_DTOR[];               // synonym for "destructor"
207 extern char const L_DYNAMIC[];
208 extern char const L_DYNAMIC_CAST[];
209 extern char const L_EXPLICIT[];
210 extern char const L_FALSE[];
211 extern char const L_FRIEND[];
212 extern char const L_MUTABLE[];
213 extern char const L_NAMESPACE[];
214 extern char const L_NEW[];
215 extern char const H_NON_THROWING[];       // English for "throw"
216 extern char const L_OPER[];               // synonym for "operator"
217 extern char const L_OPERATOR[];
218 extern char const L_PRIVATE[];
219 extern char const L_PROTECTED[];
220 extern char const L_PUBLIC[];
221 extern char const L_PURE[];
222 extern char const L_REINTERPRET[];
223 extern char const L_REINTERPRET_CAST[];
224 extern char const L_SCOPE[];
225 extern char const L_STATIC_CAST[];
226 extern char const L_TEMPLATE[];
227 extern char const L_THIS[];
228 extern char const L_THROW[];
229 extern char const L_TRUE[];
230 extern char const L_TRY[];
231 extern char const L_TYPEID[];
232 extern char const L_TYPENAME[];
233 extern char const L_USING[];
234 extern char const L_VIRTUAL[];
235 
236 // C++11
237 extern char const L_ALIGNAS[];
238 extern char const L_ALIGNOF[];
239 extern char const L_CARRIES_DEPENDENCY[];
240 extern char const L_CARRIES[], L_DEPENDENCY[];
241 extern char const H_CARRIES_DEPENDENCY[]; // English for "carries_dependency"
242 extern char const L_CONSTEXPR[];
243 extern char const L_DECLTYPE[];
244 extern char const L_FINAL[];
245 extern char const L_NOEXCEPT[];
246 extern char const L_EXCEPT[];
247 extern char const L_NORETURN[];
248 extern char const L_LITERAL[];
249 extern char const H_NO_EXCEPT[];          // English for "noexcept"
250 extern char const H_NO_EXCEPTION[];       // English for "noexcept"
251 extern char const L_NULLPTR[];
252 extern char const L_OVERRIDE[];
253 extern char const L_OVERRIDDEN[];         // English for "override"
254 extern char const L_STATIC_ASSERT[];
255 extern char const L_THREAD_LOCAL[];
256 extern char const H_USER_DEF[];           // synonym for "user-defined"
257 extern char const H_USER_DEFINED[];
258 
259 // C11 & C++11
260 extern char const L_CHAR16_T[];
261 extern char const L_CHAR32_T[];
262 
263 // C2X & C++14
264 extern char const L_DEPRECATED[];
265 extern char const L___DEPRECATED__[];
266 
267 // C++17
268 extern char const L_MAYBE_UNUSED[];
269 extern char const L_MAYBE[], L_UNUSED[];
270 extern char const H_MAYBE_UNUSED[];       // English for "maybe_unused"
271 extern char const L___MAYBE_UNUSED__[];
272 extern char const L_NODISCARD[];
273 extern char const L_DISCARD[];
274 extern char const H_NO_DISCARD[];         // English for "nodiscard"
275 extern char const L___NODISCARD__[];
276 extern char const H_NON_DISCARDABLE[];    // English for "nodiscard"
277 
278 // C++20
279 extern char const L_CHAR8_T[];
280 extern char const L_CONCEPT[];
281 extern char const L_CONSTEVAL[];
282 extern char const L_CONSTINIT[];
283 extern char const L_CO_AWAIT[];
284 extern char const L_CO_RETURN[];
285 extern char const L_CO_YIELD[];
286 extern char const L_EXPORT[];
287 extern char const L_EXPORTED[];           // English for "export"
288 extern char const L_NO_UNIQUE_ADDRESS[];
289 extern char const L_UNIQUE[], L_ADDRESS[];
290 extern char const H_NO_UNIQUE_ADDRESS[];  // English for "no_unique_address"
291 extern char const H_NON_UNIQUE_ADDRESS[]; // English for "no_unique_address"
292 extern char const L_REQUIRES[];
293 
294 // Alternative tokens
295 extern char const L_AND[];                // &&
296 extern char const L_AND_EQ[];             // &=
297 extern char const L_BITAND[];             // &
298 extern char const L_BITOR[];              // |
299 extern char const L_COMPL[];              // ~
300 extern char const L_NOT[];                // !
301 extern char const L_NOT_EQ[];             // !=
302 extern char const L_OR[];                 // ||
303 extern char const L_OR_EQ[];              // |=
304 extern char const L_XOR[];                // ^
305 extern char const L_XOR_EQ[];             // ^=
306 
307 // Embedded C extensions
308 extern char const L_EMC__ACCUM[];
309 extern char const L_EMC_ACCUM[];          // synonym for "_Accum"
310 extern char const L_EMC__FRACT[];
311 extern char const L_EMC_FRACT[];          // synonym for "_Fract"
312 extern char const L_EMC__SAT[];
313 extern char const L_EMC_SAT[];            // synonym for "_Sat"
314 extern char const L_EMC_SATURATED[];      // English for "_Sat"
315 
316 // Unified Parallel C extensions
317 extern char const L_UPC_RELAXED[];
318 extern char const L_UPC_SHARED[];
319 extern char const L_UPC_STRICT[];
320 
321 // GNU extensions
322 extern char const L_GNU___ATTRIBUTE__[];
323 extern char const L_GNU___AUTO_TYPE[];
324 extern char const L_GNU___COMPLEX[];
325 extern char const L_GNU___COMPLEX__[];
326 extern char const L_GNU___CONST[];
327 extern char const L_GNU___INLINE[];
328 extern char const L_GNU___INLINE__[];
329 extern char const L_GNU___RESTRICT[];
330 extern char const L_GNU___RESTRICT__[];
331 extern char const L_GNU___SIGNED[];
332 extern char const L_GNU___SIGNED__[];
333 extern char const L_GNU___THREAD[];
334 extern char const L_GNU___VOLATILE[];
335 extern char const L_GNU___VOLATILE__[];
336 
337 // Apple extensions
338 extern char const L_APPLE___BLOCK[];      // storage class
339 extern char const L_APPLE_BLOCK[];        // Engligh for '^'
340 
341 // Microsoft extensions
342 //
343 // Only some of these keywords have both two and one leading underscore; see
344 // <https://docs.microsoft.com/en-us/cpp/cpp/keywords-cpp?#microsoft-specific-c-keywords>.
345 extern char const L_MSC__ASM[];
346 extern char const L_MSC___ASM[];
347 extern char const L_MSC__CDECL[];
348 extern char const L_MSC___CDECL[];
349 extern char const L_MSC_CDECL[];          // English for "__cdecl"
350 extern char const L_MSC___CLRCALL[];
351 extern char const L_MSC_CLRCALL[];        // English for "__clrcall"
352 extern char const L_MSC__DECLSPEC[];
353 extern char const L_MSC___DECLSPEC[];
354 extern char const L_MSC__FASTCALL[];
355 extern char const L_MSC___FASTCALL[];
356 extern char const L_MSC_FASTCALL[];       // English for "__fastcall"
357 extern char const L_MSC__FORCEINLINE[];
358 extern char const L_MSC___FORCEINLINE[];
359 extern char const L_MSC__INLINE[];
360 extern char const L_MSC__RESTRICT[];
361 extern char const L_MSC__STDCALL[];
362 extern char const L_MSC___STDCALL[];
363 extern char const L_MSC_STDCALL[];        // English for "__stdcall"
364 extern char const L_MSC___THISCALL[];
365 extern char const L_MSC_THISCALL[];       // English for "__thiscall"
366 extern char const L_MSC__VECTORCALL[];
367 extern char const L_MSC___VECTORCALL[];
368 extern char const L_MSC_VECTORCALL[];     // English for "__vectorcall"
369 extern char const L_MSC_WINAPI[];         // synonym for "__stdcall"
370 
371 ////////// extern functions ///////////////////////////////////////////////////
372 
373 /**
374  * Gets the alignas literal for the current language.
375  *
376  * @return Returns either `_Alignas` (for C) or `alignas` (for C++).
377  */
378 C_LITERALS_INLINE PJL_WARN_UNUSED_RESULT
alignas_lang(void)379 char const* alignas_lang( void ) {
380   return OPT_LANG_IS(C_ANY) ? L__ALIGNAS : L_ALIGNAS;
381 }
382 
383 ///////////////////////////////////////////////////////////////////////////////
384 
385 /** @} */
386 
387 #endif /* cdecl_literals_H */
388 /* vim:set et sw=2 ts=2: */
389