Split alisp.h into several header files, in /include folder.

This commit is contained in:
2026-02-04 19:26:56 +00:00
parent 27108aa811
commit 7f8412fe5a
19 changed files with 539 additions and 311 deletions

21
main.c
View File

@@ -9,12 +9,15 @@
#include <stdio.h>
#include <string.h>
#include "./alisp.h"
#include <alisp/alisp.h>
const char *TOKEN_DELIM = "\n ";
int main(void)
{
sym_table_t table = {0};
sym_table_init(&table);
char filename[] = "./lorem.txt";
FILE *fp = fopen(filename, "r");
stream_t stream = {0};
@@ -25,12 +28,24 @@ int main(void)
// Skip forward any delimiters
stream_while(&stream, TOKEN_DELIM);
// Get the token (up until delimiter)
sv_t token = stream_till(&stream, TOKEN_DELIM);
printf("%s[%lu] => `" PR_SV "`\n", stream.name, token_no, SV_FMT(token));
sv_t token = stream_till(&stream, TOKEN_DELIM);
char *interned = sym_table_find(&table, token);
printf("%s[%lu] => `%s`\n", stream.name, token_no, interned);
}
printf("\nTable count=%lu\n", table.count);
for (u64 i = 0, j = 0; i < table.capacity; ++i)
{
sv_t token = VEC_GET(&table.entries, i, sv_t);
if (!token.data)
continue;
printf("[%lu]@[%lu] => `" PR_SV "`\n", j, i, SV_FMT(token));
++j;
}
stream_stop(&stream);
fclose(fp);
sym_table_cleanup(&table);
return 0;
}