From 925c4fa86368f019c683be18a641b660a42d06e5 Mon Sep 17 00:00:00 2001 From: bpc2003 Date: Fri, 7 Mar 2025 10:18:58 -0500 Subject: Finished bytecode parser --- src/main.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 64c5de2..56253a6 100644 --- a/src/main.c +++ b/src/main.c @@ -15,11 +15,26 @@ int main(int argc, char **argv) if (buf == NULL) exit(0); struct byte *bytes = parse(buf); + free(buf); + for (int i = 0; i < blen; ++i) { - printf("%d\n", bytes[i].type); + switch (bytes[i].type) { + case BEGIN: + printf("BEGIN\n"); + break; + case END: + printf("END\n"); + break; + case PAIR: + printf("PAIR: %s\n", bytes[i].value); + free(bytes[i].value); + break; + case ERROR: + fprintf(stderr, "%s\n", bytes[i].value); + exit(1); + } } free(bytes); - free(buf); exit(0); } -- cgit v1.2.3