8#ifndef ELLIPSIS_TLIST_H
9#define ELLIPSIS_TLIST_H 1
25#define STRINGIFY(...) STRINGIFY_(__VA_ARGS__)
26#define STRINGIFY_(...) #__VA_ARGS__
28#define ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR, ...) \
30 static char const contract_format_ ## COUNT[] = \
31 __FILE__ ":" STRINGIFY(__LINE__) ": violation of " CTYPE " `" CSTR "`" __VA_OPT__(", ") __VA_ARGS__ "\n";\
33 ? fputs(contract_format_ ## COUNT, stderr) \
37#define ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) \
40 : (ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR __VA_OPT__(,) __VA_ARGS__) \
45#define ELLIPSIS_TO_VOIDS(...) ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__))))
47#define ELLIPSIS_TEST_ICE(...) (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr)
49#define ELLIPSIS_CONTRACT_ICE_OR_TRUE(...) \
51 ELLIPSIS_TEST_ICE(__VA_ARGS__), \
52 ellipsis‿contracts‿is_ice*: (__VA_ARGS__), \
55#define ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR, ...) \
57 static_assert(ELLIPSIS_CONTRACT_ICE_OR_TRUE(COND), \
58 "compile time violation of " CTYPE " " CSTR \
59 __VA_OPT__(", ") __VA_ARGS__ );\
62#define ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) \
66 ELLIPSIS_TEST_ICE(COND), \
67 ellipsis‿contracts‿is_ice*: ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR __VA_OPT__(,) __VA_ARGS__), \
68 default: ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE __VA_OPT__(,) __VA_ARGS__));\
92 [[deprecated]] mtx_t
mtx;
94 [[deprecated]] cnd_t
cnd;
114 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
117 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
118 [[__maybe_unused__]]
register bool defer_return_flag =
false;
121 goto DEFER_END_ID_1_2;
124 do {
ELLIPSIS_CONTRACT(1, __LOC_ID_0_1, abort,
true,
"__LOC_ID_0_1",
"assertion",
"attempt to initialize an invalid token list");}
while (
false);
126 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
127 unsigned (*DEFER_LOC_ID_1_1)[DEFER_LOC_ID_0_2] = {};
130 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
131 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
132 {
ELLIPSIS_CONTRACT(2, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"unable to initialize a token list");}
137 extern typeof(ellipsis‿token‿list‿init) ellipsis‿token‿list‿init‿_Insta;
140 defer_return_flag =
true;
141 DEFER_LOC_ID_0_1 = ellipsis‿token‿list‿init‿_Insta(__LOC_ID_0_1);
147[[__maybe_unused__]] DEFER_END_ID_1_2:;
148 return DEFER_LOC_ID_0_1;
159 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
162 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
163 [[__maybe_unused__]]
register bool defer_return_flag =
false;
166 goto DEFER_END_ID_1_4;
169 do {
ELLIPSIS_CONTRACT(3, __LOC_ID_0_2, abort,
true,
"__LOC_ID_0_2",
"assertion",
"attempt to copy an an invalid token list");}
while (
false);
171 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
172 unsigned (*DEFER_LOC_ID_1_2)[DEFER_LOC_ID_0_2] = {};
175 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
176 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
177 {
ELLIPSIS_CONTRACT(4, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"unable to copy a token list");}
182 extern typeof(ellipsis‿token‿list‿cpy) ellipsis‿token‿list‿cpy‿_Insta;
185 defer_return_flag =
true;
186 DEFER_LOC_ID_0_1 = ellipsis‿token‿list‿cpy‿_Insta(__LOC_ID_0_2);
192[[__maybe_unused__]] DEFER_END_ID_1_4:;
193 return DEFER_LOC_ID_0_1;
207 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
210 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
211 [[__maybe_unused__]]
register bool defer_return_flag =
false;
214 goto DEFER_END_ID_1_6;
217 do {
ELLIPSIS_CONTRACT(5, __LOC_ID_0_3, abort,
true,
"__LOC_ID_0_3",
"assertion",
"attempt to stringify an an invalid token list");}
while (
false);
219 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
220 unsigned (*DEFER_LOC_ID_1_3)[DEFER_LOC_ID_0_2] = {};
223 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
224 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
225 {
ELLIPSIS_CONTRACT(6, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), unreachable,
false,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assumption",
"unable to stringify a token list");}
230 extern typeof(ellipsis‿token‿list‿stringify) ellipsis‿token‿list‿stringify‿_Insta;
233 defer_return_flag =
true;
234 DEFER_LOC_ID_0_1 = ellipsis‿token‿list‿stringify‿_Insta(__LOC_ID_0_3);
240[[__maybe_unused__]] DEFER_END_ID_1_6:;
241 return DEFER_LOC_ID_0_1;
246 typeof(
size_t) DEFER_LOC_ID_0_1;
247 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
248 DEFER_LOC_ID_0_1 = (typeof(
size_t)) {};
250 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
251 [[__maybe_unused__]]
register bool defer_return_flag =
false;
254 goto DEFER_END_ID_1_8;
257 do {
ELLIPSIS_CONTRACT(7, arg, abort,
true,
"arg",
"assertion",
"attempt to scatter into an invalid token list");}
while (
false);
258 do {
ELLIPSIS_CONTRACT(8, in, abort,
true,
"in",
"assertion",
"attempt to scatter from an invalid token list");}
while (
false);
262 defer_return_flag =
true;
269[[__maybe_unused__]] DEFER_END_ID_1_8:;
270 return DEFER_LOC_ID_0_1;
283 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
286 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
287 [[__maybe_unused__]]
register bool defer_return_flag =
false;
290 goto DEFER_END_ID_1_10;
293 do {
ELLIPSIS_CONTRACT(9, __LOC_ID_0_4, unreachable,
false,
"__LOC_ID_0_4",
"assumption",
"attempt to initialize an invalid token list");}
while (
false);
295 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
296 unsigned (*DEFER_LOC_ID_1_4)[DEFER_LOC_ID_0_2] = {};
299 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
300 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
301 {
ELLIPSIS_CONTRACT(10, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"unable to initialize a token list");}
309 defer_return_flag =
true;
316[[__maybe_unused__]] DEFER_END_ID_1_10:;
317 return DEFER_LOC_ID_0_1;
328 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
331 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
332 [[__maybe_unused__]]
register bool defer_return_flag =
false;
335 goto DEFER_END_ID_1_12;
338 do {
ELLIPSIS_CONTRACT(11, __LOC_ID_0_5, unreachable,
false,
"__LOC_ID_0_5",
"assumption",
"attempt to copy an an invalid token list");}
while (
false);
340 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
341 unsigned (*DEFER_LOC_ID_1_5)[DEFER_LOC_ID_0_2] = {};
344 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
345 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
346 {
ELLIPSIS_CONTRACT(12, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"unable to copy a token list");}
354 defer_return_flag =
true;
361[[__maybe_unused__]] DEFER_END_ID_1_12:;
362 return DEFER_LOC_ID_0_1;
376 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
379 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
380 [[__maybe_unused__]]
register bool defer_return_flag =
false;
383 goto DEFER_END_ID_1_14;
386 do {
ELLIPSIS_CONTRACT(13, __LOC_ID_0_6, unreachable,
false,
"__LOC_ID_0_6",
"assumption",
"attempt to stringify an an invalid token list");}
while (
false);
388 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
389 unsigned (*DEFER_LOC_ID_1_6)[DEFER_LOC_ID_0_2] = {};
392 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
393 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
394 {
ELLIPSIS_CONTRACT(14, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)",
"assertion",
"unable to stringify a token list");}
402 defer_return_flag =
true;
409[[__maybe_unused__]] DEFER_END_ID_1_14:;
410 return DEFER_LOC_ID_0_1;
415 typeof(
size_t) DEFER_LOC_ID_0_1;
416 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
417 DEFER_LOC_ID_0_1 = (typeof(
size_t)) {};
419 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
420 [[__maybe_unused__]]
register bool defer_return_flag =
false;
423 goto DEFER_END_ID_1_16;
426 do {
ELLIPSIS_CONTRACT(15, arg, unreachable,
false,
"arg",
"assumption",
"attempt to scatter into an invalid token list");}
while (
false);
427 do {
ELLIPSIS_CONTRACT(16, in, unreachable,
false,
"in",
"assumption",
"attempt to scatter from an invalid token list");}
while (
false);
431 defer_return_flag =
true;
438[[__maybe_unused__]] DEFER_END_ID_1_16:;
439 return DEFER_LOC_ID_0_1;
525 ellipsis‿token‿list‿delete((
void*)*__LOC_ID_0_7);
527 *__LOC_ID_0_7= *__LOC_ID_0_8;
528 *__LOC_ID_0_8=
nullptr;
530 *__LOC_ID_0_7=
nullptr;
544 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
547 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
548 [[__maybe_unused__]]
register bool defer_return_flag =
false;
551 goto DEFER_END_ID_1_18;
555 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
556 unsigned (*DEFER_LOC_ID_1_7)[DEFER_LOC_ID_0_2] = {};
559 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
560 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
561 {
ELLIPSIS_CONTRACT(17, ((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1), abort,
true,
"defer_return_value",
"postcondition",
"unable to allocate token list");}
567 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
568 unsigned (*DEFER_LOC_ID_1_8)[DEFER_LOC_ID_0_2] = {};
571 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
572 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
573 {
if (((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1)) ellipsis‿token‿list‿init(((typeof(DEFER_LOC_ID_0_1))DEFER_LOC_ID_0_1));}
580 defer_return_flag =
true;
587[[__maybe_unused__]] DEFER_END_ID_1_18:;
588 return DEFER_LOC_ID_0_1;
#define STDC_ATTR_NODISCARD(...)
Definition ellipsis-error.h:68
struct ellipsis‿contracts‿is_ice ellipsis‿contracts‿is_ice
Definition ellipsis-expression.c:24
ellipsis‿malloc ellipsis‿malloc
Definition ellipsis-malloc.c:10
ELLIPSIS_FA_UNDEPRECATE void ellipsis‿token‿list‿wait(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:600
ELLIPSIS_FA_UNDEPRECATE ellipsis‿token‿list * ellipsis‿token‿list‿cpy‿_Inner(ellipsis‿token‿list tl[static const 1])
Definition ellipsis-tlist.c:89
ELLIPSIS_FA_UNDEPRECATE void ellipsis‿token‿list‿destroy(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:801
ELLIPSIS_FA_UNDEPRECATE ellipsis‿token‿list * ellipsis‿token‿list‿init‿_Inner(ellipsis‿token‿list tl[static const 1])
Definition ellipsis-tlist.c:81
ELLIPSIS_FA_UNDEPRECATE ellipsis‿str32 * ellipsis‿token‿list‿stringify‿_Inner(ellipsis‿token‿list const source[static const 1])
Definition ellipsis-tlist.c:98
ELLIPSIS_FA_UNDEPRECATE bool ellipsis‿token‿list‿is_finished(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:636
ELLIPSIS_FA_UNDEPRECATE token * ellipsis‿token‿list‿all(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:442
ELLIPSIS_FA_UNDEPRECATE size_t ellipsis‿token‿list‿scatter‿_Inner(size_t len, ellipsis‿token‿list arg[static restrict len], ellipsis‿token‿list in[restrict static 1], bool var, bool call, ellipsis‿str32 const **space)
Definition ellipsis-tlist.c:132
ELLIPSIS_FA_UNDEPRECATE void ellipsis‿token‿list‿open(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:551
token * ellipsis‿token‿list‿last(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:835
token * ellipsis‿token‿list‿first(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:831
ELLIPSIS_FA_UNDEPRECATE void ellipsis‿token‿list‿append(ellipsis‿token‿list tl[static 1], token *to)
Definition ellipsis-tlist.c:515
token const * ellipsis‿token‿list‿top(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:827
ELLIPSIS_FA_UNDEPRECATE void ellipsis‿token‿list‿push(ellipsis‿token‿list target[static 1], ellipsis‿token‿list source[static 1])
Definition ellipsis-tlist.c:738
ELLIPSIS_FA_UNDEPRECATE void ellipsis‿token‿list‿close(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:575
ELLIPSIS_FA_UNDEPRECATE token * ellipsis‿token‿list‿pop(ellipsis‿token‿list tl[static 1])
Definition ellipsis-tlist.c:366
size_t ellipsis‿token‿list‿scatter‿_Insta(size_t len, ellipsis‿token‿list arg[static len], ellipsis‿token‿list in[restrict static 1], bool var, bool call, ellipsis‿str32 const **space)
Definition ellipsis-tlist.c:337
ELLIPSIS_FA_UNDEPRECATE void ellipsis‿token‿list‿flush(ellipsis‿token‿list target[static 1], ellipsis‿token‿list source[static 1])
Definition ellipsis-tlist.c:675
size_t ellipsis‿token‿list‿scatter‿_Ctra(size_t len, ellipsis‿token‿list arg[static len], ellipsis‿token‿list in[restrict static 1], bool var, bool call, ellipsis‿str32 const **space)
Definition ellipsis-tlist.h:414
thread_local bool volatile ellipsis‿contracts‿verbose‿dynamic
#define ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE,...)
Definition ellipsis-tlist.h:62
ellipsis‿token token
Definition ellipsis-tlist.h:71
thread_local bool volatile ellipsis‿contracts‿proceed‿dynamic
size_t ellipsis‿token‿list‿scatter(size_t len, ellipsis‿token‿list arg[static len], ellipsis‿token‿list in[restrict static 1], bool var, bool call, ellipsis‿str32 const **space)
Definition ellipsis-tlist.h:245
thread_local bool volatile ellipsis‿contracts‿ignore‿dynamic
A structure with a flexible array member of base type ellipsis‿str32‿base.
Definition ellipsis-str32.h:156
A token element as recognized during processing.
Definition ellipsis-token.h:94
a token list
Definition ellipsis-tlist.h:84
ellipsis‿token‿list * ellipsis‿token‿list‿init(ellipsis‿token‿list __LOC_ID_0_1[static const 1])
Initialize a token list.
Definition ellipsis-tlist.h:112
size_t ellipsis‿token‿list‿collect_call(size_t len, ellipsis‿token‿list arg[static len], ellipsis‿token‿list in[restrict static 1], bool var, ellipsis‿str32 const *space[static 1])
collect the arguments for_DEFER_REPLAY_FOR a macro call
bool ellipsis‿token‿list‿equiv(ellipsis‿token‿list *a, ellipsis‿token‿list *b)
Check if two token lists are token equivalent.
void ellipsis‿token‿list‿move(ellipsis‿token‿list *__LOC_ID_0_7[restrict static 1], ellipsis‿token‿list **restrict __LOC_ID_0_8)
Move a ellipsis‿token‿list pointed to by the second parameter to the one pointed to by the first.
Definition ellipsis-tlist.h:523
token * first
Definition ellipsis-tlist.h:96
cnd_t cnd
Definition ellipsis-tlist.h:94
bool finished
Definition ellipsis-tlist.h:100
void ellipsis‿token‿list‿delete(ellipsis‿token‿list *tl)
delete all tokens and free the list itself
Definition ellipsis-tlist.h:508
token * last
Definition ellipsis-tlist.h:98
ellipsis‿token‿list * ellipsis‿token‿list‿cpy(ellipsis‿token‿list __LOC_ID_0_2[static const 1])
create a new token list by deep copying the pointed to token list
Definition ellipsis-tlist.h:157
mtx_t mtx
Definition ellipsis-tlist.h:92
ellipsis‿token‿list * ellipsis‿token‿list‿init‿_Ctra(ellipsis‿token‿list __LOC_ID_0_4[static const 1])
Initialize a token list.
Definition ellipsis-tlist.h:281
ellipsis‿token‿list * ellipsis‿token‿list‿cpy‿_Ctra(ellipsis‿token‿list __LOC_ID_0_5[static const 1])
create a new token list by deep copying the pointed to token list
Definition ellipsis-tlist.h:326