43static inline tok_t tok(
const char *input,
const char *separators) {
45 assert(input !=
NULL);
46 assert(separators !=
NULL);
47 assert(strcmp(separators,
"") != 0 &&
48 "at least one separator must be provided");
51 for (
const char *
s1 = separators; *
s1 !=
'\0'; ++
s1) {
52 for (
const char *s2 =
s1 + 1; *s2 !=
'\0'; ++s2) {
53 assert(*
s1 != *s2 &&
"duplicate separator characters");
58 tok_t t = {.
start = input, .separators = separators};
61 size_t size = strcspn(input, separators);
79 assert(t->
next.
data !=
NULL &&
"extracting from an exhausted tokenizer");
90 assert(t->
next.
data !=
NULL &&
"advancing an exhausted tokenizer");
NEATOPROCS_API void s1(graph_t *, node_t *)
a non-owning string reference
const char * data
start of the pointed to string
size_t size
extent of the string in bytes
state for an in-progress string tokenization
strview_t next
next token to yield
const char * separators
characters to treat as token separators
const char * start
start of the string being scanned
Non-owning string references.
static strview_t tok_get(const tok_t *t)
get the current token
static tok_t tok(const char *input, const char *separators)
begin tokenization of a new string
static bool tok_end(const tok_t *t)
is this tokenizer exhausted?
static void tok_next(tok_t *t)
advance to the next token in the string being scanned