The main function will now write out the output of the parser.

This commit is contained in:
2022-08-29 21:23:02 +00:00
parent 6c7b8d5356
commit 3c7056c5e6
4 changed files with 22 additions and 34 deletions
+18 -11
View File
@@ -1,3 +1,4 @@
#include <bits/types/FILE.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -21,22 +22,28 @@ int main(int argc, char* args[]) {
List* list = GenerateTokenList(source_code);
for(int i = 0; i < list->size; i++) {
Token* t = (Token*) list->content[i];
// for(int i = 0; i < list->size; i++) {
// Token* t = (Token*) list->content[i];
if (t->type == LineEnd) {
if (i - 1 >= 0 && ((Token*) list->content[i - 1])->type != LineEnd)
printf("\n");
// if (t->type == LineEnd) {
// if (i - 1 >= 0 && ((Token*) list->content[i - 1])->type != LineEnd)
// printf("\n");
continue;
}
// continue;
// }
printf("[T: %i][C: %i] '%s' ", t->type, t->token_class, t->lexeme);
if (t->type == LABEL) printf("* ");
}
// printf("[T: %i][C: %i] '%s' ", t->type, t->token_class, t->lexeme);
// if (t->type == LABEL) printf("* ");
// }
unsigned char* image = ParseTokens(list);
Disassemble(image);
//Disassemble(image);
FILE* program = fopen("program.bin", "w+b");
fwrite(image, 1, image[2] + image[3], program);
fclose(program);
free(source_code);
}