diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-26 07:15:52 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-10-26 07:15:52 +0100 |
commit | 7bf6b53230868f419331bc7ef2044b02502aae76 (patch) | |
tree | 91e36d235a9f125f80a8bd388abffacfd766cf27 /asm/main.c | |
parent | 131d70a9a37bdbfacaea9cfe2f78867dd9e16942 (diff) | |
download | ovm-7bf6b53230868f419331bc7ef2044b02502aae76.tar.gz ovm-7bf6b53230868f419331bc7ef2044b02502aae76.tar.bz2 ovm-7bf6b53230868f419331bc7ef2044b02502aae76.zip |
Unified literal for numbers, main program now tokenises
Diffstat (limited to 'asm/main.c')
-rw-r--r-- | asm/main.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -20,18 +20,18 @@ int main(void) darr_t buffer = darr_read_file(fp); fclose(fp); - size_t n = 0; - token_t *tokens = tokenise_buffer(&buffer, &n); - printf("%lu bytes -> %lu tokens\n", buffer.used, n); + token_stream_t tokens = tokenise_buffer(&buffer); + printf("%lu bytes -> %lu tokens\n", buffer.used, tokens.available); free(buffer.data); - for (size_t i = 0; i < n; ++i) - printf("%s(%.*s)\n", token_type_as_cstr(tokens[i].type), - (int)tokens[i].str_size, tokens[i].str); + for (size_t i = 0; i < tokens.available; ++i) + printf("%s(%.*s)\n", token_type_as_cstr(((token_t *)tokens.data)[i].type), + (int)((token_t *)tokens.data)[i].str_size, + ((token_t *)tokens.data)[i].str); // Free the tokens - for (size_t i = 0; i < n; ++i) - free(tokens[i].str); - free(tokens); + for (size_t i = 0; i < tokens.available; ++i) + free(((token_t *)tokens.data)[i].str); + free(tokens.data); return 0; } |