7#ifndef ELLIPSIS_SPACE_H
8#define ELLIPSIS_SPACE_H 1
35#define STRINGIFY(...) STRINGIFY_(__VA_ARGS__)
36#define STRINGIFY_(...) #__VA_ARGS__
38#define ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR, ...) \
40 static char const contract_format_ ## COUNT[] = \
41 __FILE__ ":" STRINGIFY(__LINE__) ": violation of " CTYPE " `" CSTR "`" __VA_OPT__(", ") __VA_ARGS__ "\n";\
43 ? fputs(contract_format_ ## COUNT, stderr) \
47#define ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) \
50 : (ELLIPSIS_CONTRACT_VIOLATION(COUNT, VERB, CTYPE, CSTR __VA_OPT__(,) __VA_ARGS__) \
55#define ELLIPSIS_TO_VOIDS(...) ((void*)((uintptr_t)((__VA_ARGS__)-(__VA_ARGS__))))
57#define ELLIPSIS_TEST_ICE(...) (false ? ELLIPSIS_TO_VOIDS(__VA_ARGS__) : (ellipsis‿contracts‿is_ice*)nullptr)
59#define ELLIPSIS_CONTRACT_ICE_OR_TRUE(...) \
61 ELLIPSIS_TEST_ICE(__VA_ARGS__), \
62 ellipsis‿contracts‿is_ice*: (__VA_ARGS__), \
65#define ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR, ...) \
67 static_assert(ELLIPSIS_CONTRACT_ICE_OR_TRUE(COND), \
68 "compile time violation of " CTYPE " " CSTR \
69 __VA_OPT__(", ") __VA_ARGS__ );\
72#define ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE, ...) \
76 ELLIPSIS_TEST_ICE(COND), \
77 ellipsis‿contracts‿is_ice*: ELLIPSIS_CONTRACT_CHECK_STATIC(CTYPE, COND, CSTR __VA_OPT__(,) __VA_ARGS__), \
78 default: ELLIPSIS_CONTRACT_IMPL(COUNT, COND, ACTION, VERB, CSTR, CTYPE __VA_OPT__(,) __VA_ARGS__));\
86 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
89 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
90 [[__maybe_unused__]]
register bool defer_return_flag =
false;
93 goto DEFER_END_ID_1_2;
97 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
98 unsigned (*DEFER_LOC_ID_1_1)[DEFER_LOC_ID_0_2] = {};
101 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
102 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
103 {
ELLIPSIS_CONTRACT(1, ((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 allocate string for non-space token");}
111 defer_return_flag =
true;
118[[__maybe_unused__]] DEFER_END_ID_1_2:;
119 return DEFER_LOC_ID_0_1;
125 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
128 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
129 [[__maybe_unused__]]
register bool defer_return_flag =
false;
132 goto DEFER_END_ID_1_4;
139 defer_return_flag =
true;
146[[__maybe_unused__]] DEFER_END_ID_1_4:;
147 return DEFER_LOC_ID_0_1;
153 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
156 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
157 [[__maybe_unused__]]
register bool defer_return_flag =
false;
160 goto DEFER_END_ID_1_6;
166 defer_return_flag =
true;
173[[__maybe_unused__]] DEFER_END_ID_1_6:;
174 return DEFER_LOC_ID_0_1;
179 typeof(
char*) DEFER_LOC_ID_0_1;
180 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
181 DEFER_LOC_ID_0_1 = (typeof(
char*)) {};
183 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
184 [[__maybe_unused__]]
register bool defer_return_flag =
false;
187 goto DEFER_END_ID_1_8;
191 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
192 unsigned (*DEFER_LOC_ID_1_2)[DEFER_LOC_ID_0_2] = {};
195 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
196 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
197 {
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 allocate string for strdup with escapes");}
205 defer_return_flag =
true;
212[[__maybe_unused__]] DEFER_END_ID_1_8:;
213 return DEFER_LOC_ID_0_1;
221 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
224 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
225 [[__maybe_unused__]]
register bool defer_return_flag =
false;
228 goto DEFER_END_ID_1_10;
232 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
233 unsigned (*DEFER_LOC_ID_1_3)[DEFER_LOC_ID_0_2] = {};
236 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
237 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
238 {
ELLIPSIS_CONTRACT(3, ((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 allocate string for non-space token");}
246 defer_return_flag =
true;
253[[__maybe_unused__]] DEFER_END_ID_1_10:;
254 return DEFER_LOC_ID_0_1;
260 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
263 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
264 [[__maybe_unused__]]
register bool defer_return_flag =
false;
267 goto DEFER_END_ID_1_12;
274 defer_return_flag =
true;
281[[__maybe_unused__]] DEFER_END_ID_1_12:;
282 return DEFER_LOC_ID_0_1;
288 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
291 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
292 [[__maybe_unused__]]
register bool defer_return_flag =
false;
295 goto DEFER_END_ID_1_14;
301 defer_return_flag =
true;
308[[__maybe_unused__]] DEFER_END_ID_1_14:;
309 return DEFER_LOC_ID_0_1;
314 typeof(
char*) DEFER_LOC_ID_0_1;
315 if (__func__[0] ==
'm' && __func__[1] ==
'a' && __func__[2] ==
'i' && __func__[3] ==
'n' && !__func__[4]) {
316 DEFER_LOC_ID_0_1 = (typeof(
char*)) {};
318 [[__maybe_unused__]]
register unsigned DEFER_LOC_ID_0_2 = 1U;
319 [[__maybe_unused__]]
register bool defer_return_flag =
false;
322 goto DEFER_END_ID_1_16;
326 [[__maybe_unused__, __deprecated__(
"dummy variable for better diagnostics")]]
327 unsigned (*DEFER_LOC_ID_1_4)[DEFER_LOC_ID_0_2] = {};
330 [[__maybe_unused__, __deprecated__(
"invalid termination of a deferred block")]]
331 register bool const defer_return_flag =
false, defer_break_flag =
false, defer_continue_flag =
false;
332 {
ELLIPSIS_CONTRACT(4, ((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 allocate string for strdup with escapes");}
340 defer_return_flag =
true;
347[[__maybe_unused__]] DEFER_END_ID_1_16:;
348 return DEFER_LOC_ID_0_1;
364 case U
'\t' :
return true;
365 case U
' ' :
return true;
366 case U
' ':
return true;
367 case U
' ':
return true;
368 case U
' ':
return true;
369 case U
' ':
return true;
370 case U
' ':
return true;
371 case U
' ':
return true;
372 case U
' ':
return true;
373 case U
' ':
return true;
374 case U
' ':
return true;
375 case U
' ':
return true;
376 case U
' ':
return true;
377 case U
' ':
return true;
378 case U
' ':
return true;
379 case U
' ':
return true;
380 case U
' ':
return true;
381 case U
' ':
return true;
382 default:
return false;
390 default: *pc32 = U
'\\';
break;
392 case '\\': *pc32 = U
'\\'; l = 2;
break;
393 case 'a': *pc32 = U
'\a'; l = 2;
break;
394 case 'b': *pc32 = U
'\b'; l = 2;
break;
395 case 'f': *pc32 = U
'\f'; l = 2;
break;
396 case 'n': *pc32 = U
'\n'; l = 2;
break;
397 case 'r': *pc32 = U
'\r'; l = 2;
break;
398 case 't': *pc32 = U
'\t'; l = 2;
break;
399 case 'v': *pc32 = U
'\v'; l = 2;
break;
400 case '\"': *pc32 = U
'\"'; l = 2;
break;
401 case '\'': *pc32 = U
'\''; l = 2;
break;
406 if (sscanf(s+2,
"%4" SCNx32, pc32) < 1) {
415 if (sscanf(s+2,
"%8" SCNx32, pc32) < 1) {
432 default: *pc =
'\\';
break;
434 case '\\': *pc =
'\\'; l = 2;
break;
435 case 'a': *pc =
'\a'; l = 2;
break;
436 case 'b': *pc =
'\b'; l = 2;
break;
437 case 'f': *pc =
'\f'; l = 2;
break;
438 case 'n': *pc =
'\n'; l = 2;
break;
439 case 'r': *pc =
'\r'; l = 2;
break;
440 case 't': *pc =
'\t'; l = 2;
break;
441 case 'v': *pc =
'\v'; l = 2;
break;
442 case '\"': *pc =
'\"'; l = 2;
break;
443 case '\'': *pc =
'\''; l = 2;
break;
456 if (sscanf(s+1,
"%3" SCNo32
"%n", &c32, &el) < 1) {
465 size_t len = c32rtomb(pc, c32, &(mbstate_t) {});
466 ELLIPSIS_CONTRACT(5, len <= MB_CUR_MAX, abort,
true,
"len ≤ MB_CUR_MAX",
"assertion",
"Unable to convert octal escape character");
475 if (sscanf(s+2,
"%" SCNx32
"%n", &c32, &el) < 1) {
484 size_t len = c32rtomb(pc, c32, &(mbstate_t) {});
485 ELLIPSIS_CONTRACT(6, len <= MB_CUR_MAX, abort,
true,
"len ≤ MB_CUR_MAX",
"assertion",
"Unable to convert hexadecimal escape character");
494 if (sscanf(s+2,
"%4" SCNx32, &c32) < 1) {
498 size_t len = c32rtomb(pc, c32, &(mbstate_t) {});
499 ELLIPSIS_CONTRACT(7, len <= MB_CUR_MAX, abort,
true,
"len ≤ MB_CUR_MAX",
"assertion",
"unable to convert short Unicode identifier");
506 if (sscanf(s+2,
"%8" SCNx32, &c32) < 1) {
510 size_t len = c32rtomb(pc, c32, &(mbstate_t) {});
511 ELLIPSIS_CONTRACT(8, len <= MB_CUR_MAX, abort,
true,
"len ≤ MB_CUR_MAX",
"assertion",
"unable to convert long Unicode identifier");
ellipsis‿bitset‿base ellipsis‿XID‿Continue[0x1000]
Definition XID_Continue.c:8
ellipsis‿bitset‿base ellipsis‿XID‿Start[0x1000]
Definition XID_Start.c:8
#define ellipsis_bitset_member(A, V)
Definition ellipsis-bitset.h:46
ellipsis‿category
An enumeration type ellipsis‿category with the underlying integer type ellipsis‿category‿base.
Definition ellipsis-category.h:32
struct ellipsis‿contracts‿is_ice ellipsis‿contracts‿is_ice
Definition ellipsis-expression.c:24
void ellipsis‿infra‿newline(void)
Definition ellipsis-infra.c:158
ellipsis‿category ellipsis‿lex‿category‿_Inner(ellipsis‿str32 const st[static 1], ellipsis‿special‿find *find)
Definition ellipsis-lexer.c:428
char * ellipsis‿lex‿strdup_escape‿_Inner(size_t len, char const s[static len], size_t nlenp[static 1])
Definition ellipsis-lexer.c:443
ellipsis‿category ellipsis‿lex‿category‿_Insta(ellipsis‿str32 const s[static 1], ellipsis‿special‿find *find)
Definition ellipsis-lexer.c:599
ellipsis‿str32 const * ellipsis‿lex‿space‿_Inner(size_t len[static 1], char const *restrict s[static 1])
Definition ellipsis-lexer.c:503
ellipsis‿str32 const * ellipsis‿lex‿nonspace‿_Insta(size_t len[static 1], char const *restrict s[static 1], ellipsis‿special const **sp, ellipsis‿token t[static 1], ellipsis‿special‿find *f)
Definition ellipsis-lexer.c:541
ellipsis‿str32 const * ellipsis‿lex‿nonspace‿_Inner(size_t len[static 1], char const *restrict s[static 1], ellipsis‿special const **sp, ellipsis‿token t[static 1], ellipsis‿special‿find *find)
Definition ellipsis-lexer.c:184
ellipsis‿str32 const * ellipsis‿lex‿space‿_Insta(size_t len[static 1], char const *restrict s[static 1])
Definition ellipsis-lexer.c:571
char * ellipsis‿lex‿strdup_escape‿_Insta(size_t len, char const s[static len], size_t nlenp[static 1])
Definition ellipsis-lexer.c:626
ellipsis‿str32 const * ellipsis‿lex‿space‿_Ctra(size_t len[static 1], char const *restrict s[static 1])
Definition ellipsis-lexer.h:258
thread_local bool volatile ellipsis‿contracts‿verbose‿dynamic
char * ellipsis‿lex‿strdup_escape(size_t len, char const s[static len], size_t nlenp[static 1])
Definition ellipsis-lexer.h:178
#define ELLIPSIS_CONTRACT(COUNT, COND, ACTION, VERB, CSTR, CTYPE,...)
Definition ellipsis-lexer.h:72
ellipsis‿str32 const * ellipsis‿lex‿space(size_t len[static 1], char const *restrict s[static 1])
Definition ellipsis-lexer.h:123
bool ellipsis‿lex‿is_space(char32_t c)
Definition ellipsis-lexer.h:362
bool ellipsis‿lex‿Start(char32_t val)
Definition ellipsis-lexer.h:352
ellipsis‿category ellipsis‿lex‿category(ellipsis‿str32 const s[static 1], ellipsis‿special‿find *find)
Definition ellipsis-lexer.h:151
ellipsis‿str32 const * ellipsis‿lex‿nonspace‿_Ctra(size_t len[static 1], char const *restrict s[static 1], ellipsis‿special const **sp, ellipsis‿token t[static 1], ellipsis‿special‿find *f)
Definition ellipsis-lexer.h:217
thread_local bool volatile ellipsis‿contracts‿proceed‿dynamic
ellipsis‿str32 const * ellipsis‿lex‿nonspace(size_t len[static 1], char const *restrict s[static 1], ellipsis‿special const **sp, ellipsis‿token t[static 1], ellipsis‿special‿find *f)
Definition ellipsis-lexer.h:82
size_t ellipsis‿lex‿str_escape(char pc[static 1], size_t lenp[static 1], char const s[static 2], bool account_eol)
Definition ellipsis-lexer.h:427
ellipsis‿category ellipsis‿lex‿category‿_Ctra(ellipsis‿str32 const s[static 1], ellipsis‿special‿find *find)
Definition ellipsis-lexer.h:286
size_t ellipsis‿str32‿escape(char32_t *pc32, char const *s, bool account_eol)
Definition ellipsis-lexer.h:387
bool ellipsis‿lex‿Continue(char32_t val)
Definition ellipsis-lexer.h:357
thread_local bool volatile ellipsis‿contracts‿ignore‿dynamic
char * ellipsis‿lex‿strdup_escape‿_Ctra(size_t len, char const s[static len], size_t nlenp[static 1])
Definition ellipsis-lexer.h:313
ellipsis‿special const * ellipsis‿special‿find(size_t len, char const buf[len])
Definition ellipsis-special.h:102
Definition ellipsis-special.h:95
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