This commit is contained in:
2025-09-27 15:16:26 +02:00
parent 5af7c5276a
commit 3b1bb9d531
63 changed files with 1087 additions and 407 deletions

View File

@ -16,32 +16,31 @@ RtAlias *RTALIASES = NULL;
} while(0)
bool rt_print(Token *tks) {
Token *tk = tks;
while (tk) {
uprintf("%.*s", (int)tk->len, tk->ptr);
Token *tk, *tktmp;
LL_FOREACH_SAFE(tks, tk, tktmp) {
writefmt("{s}", tk->str);
if (tk->next != NULL) {
uprintf(" ");
writefmt(" ");
}
tk = tk->next;
}
uprintf("\n");
writefmt("\n");
return true;
}
bool rt_mkalias(Token *tks) {
RtAlias *alias = dlmalloc(sizeof(*alias));
string_memset(alias, 0, sizeof(*alias));
Token *tk = tks;
size_t i = 0;
while (tk) {
size_t i;
Token *tk, *tktmp;
LL_FOREACH_SAFE_IDX(tks, tk, tktmp, i) {
if (i == 0) {
usprintf(alias->namebuf, "%.*s", (int)tk->len, tk->ptr);
string_memcpy(alias->namebuf, tk->str, MIN(string_len(tk->str), RTALIAS_NAMEBUF_MAX));
} else if (i == 1) {
usprintf(alias->valbuf, "%.*s", (int)tk->len, tk->ptr);
string_memcpy(alias->valbuf, tk->str, MIN(string_len(tk->str), RTALIAS_VALBUF_MAX));
}
i++;
tk = tk->next;
}
LL_APPEND(RTALIASES, alias);
return true;
}