aboutsummaryrefslogtreecommitdiff
path: root/asm
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-10-26 11:18:07 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-10-26 11:18:07 +0100
commitfc81cda96bce85a8cb0a312c724cd144e6375b58 (patch)
tree258429c314e34f9bca637335014702d87d4ff629 /asm
parent2fe2af22a9b7b2be36d51e24797330c5b6cdbb13 (diff)
downloadovm-fc81cda96bce85a8cb0a312c724cd144e6375b58.tar.gz
ovm-fc81cda96bce85a8cb0a312c724cd144e6375b58.tar.bz2
ovm-fc81cda96bce85a8cb0a312c724cd144e6375b58.zip
Plugged in asm/parser to asm/main
Just prints instructions so far.
Diffstat (limited to 'asm')
-rw-r--r--asm/main.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/asm/main.c b/asm/main.c
index 5b8c4ec..bb1a2b6 100644
--- a/asm/main.c
+++ b/asm/main.c
@@ -13,6 +13,7 @@
#include <lib/darr.h>
#include "./lexer.h"
+#include "./parser.h"
int main(void)
{
@@ -29,10 +30,20 @@ int main(void)
token_type_as_cstr((TOKEN_STREAM_AT(tokens.data, i)).type),
(int)(TOKEN_STREAM_AT(tokens.data, i).str_size),
(TOKEN_STREAM_AT(tokens.data, i).str));
-
+ puts("");
+
+ size_t number = 0;
+ inst_t *instructions = parse_stream(&tokens, &number);
+ for (size_t i = 0; i < number; ++i)
+ {
+ inst_print(instructions[i], stdout);
+ puts("");
+ }
// Free the tokens
for (size_t i = 0; i < tokens.available; ++i)
free(TOKEN_STREAM_AT(tokens.data, i).str);
free(tokens.data);
+ if (instructions)
+ free(instructions);
return 0;
}