diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 15:22:47 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-01 15:22:47 +0000 |
commit | 6d35283ef01114475b6069f1a3c24e3b537bd510 (patch) | |
tree | 25507bc7a0bb8405915e7f2a67dbb4048572a3eb /asm | |
parent | 6a270eda1e444a68d5db9102b11af9153fa58a1c (diff) | |
download | ovm-6d35283ef01114475b6069f1a3c24e3b537bd510.tar.gz ovm-6d35283ef01114475b6069f1a3c24e3b537bd510.tar.bz2 ovm-6d35283ef01114475b6069f1a3c24e3b537bd510.zip |
Clearer VERBOSE messages
Diffstat (limited to 'asm')
-rw-r--r-- | asm/main.c | 25 |
1 files changed, 24 insertions, 1 deletions
@@ -71,7 +71,19 @@ int main(int argc, char *argv[]) printf("\t[%sTOKENISER%s]: %lu bytes -> %lu tokens\n", TERM_GREEN, TERM_RESET, buffer.used, tokens.available); #endif + +#if VERBOSE >= 2 + printf("\t[%sTOKENISER%s]: Tokens parsed:\n", TERM_GREEN, TERM_RESET); + for (size_t i = 0; i < tokens.available; ++i) + { + token_t token = TOKEN_STREAM_AT(tokens.data, i); + printf("\t[%lu]: %s(`%s`)@%lu,%lu\n", i, token_type_as_cstr(token.type), + token.str, token.line, token.column); + } +#endif + free(buffer.data); + buffer.data = NULL; size_t number = 0; inst_t *instructions = NULL; @@ -96,6 +108,16 @@ int main(int argc, char *argv[]) TERM_RESET, tokens.available, number); #endif +#if VERBOSE >= 2 + printf("\t[%sPARSER%s]: Instructions parsed:\n", TERM_GREEN, TERM_RESET); + for (size_t i = 0; i < number; ++i) + { + printf("\t[%lu]: ", i); + inst_print(instructions[i], stdout); + printf("\n"); + } +#endif + fp = fopen(out_file, "wb"); insts_write_bytecode_file(instructions, number, fp); fclose(fp); @@ -104,7 +126,8 @@ int main(int argc, char *argv[]) out_file); #endif end: - // Free the tokens and parsed data + if (buffer.data) + free(buffer.data); if (tokens.data) { for (size_t i = 0; i < tokens.available; ++i) |