aboutsummaryrefslogtreecommitdiff
path: root/asm/main.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-26 07:15:52 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-26 07:15:52 +0100
commit7bf6b53230868f419331bc7ef2044b02502aae76 (patch)
tree91e36d235a9f125f80a8bd388abffacfd766cf27 /asm/main.c
parent131d70a9a37bdbfacaea9cfe2f78867dd9e16942 (diff)
downloadovm-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.c18
1 files changed, 9 insertions, 9 deletions
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;
}