From 7bf6b53230868f419331bc7ef2044b02502aae76 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 26 Oct 2023 07:15:52 +0100 Subject: Unified literal for numbers, main program now tokenises --- asm/main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'asm/main.c') diff --git a/asm/main.c b/asm/main.c index 2415fa1..c6e7782 100644 --- a/asm/main.c +++ b/asm/main.c @@ -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; } -- cgit v1.2.3-13-gbd6f