eaxhla/source/main.c
2024-07-16 10:07:20 -04:00

58 lines
961 B
C

#include <stdio.h>
#include <stdlib.h>
#include "eaxhla.h"
#include "eaxhla.yy.h"
#include "eaxhla.tab.h"
#include "compile.h"
#include "assembler.h"
#include "debug.h"
void deinit(void) {
extern void yyfree_leftovers(void);
yyfree_leftovers();
eaxhla_destroy();
free (token_array);
}
signed main(int argc, char * argv[]) {
if (argc < 2) {
printf("%s: <file>\n", argv[0]);
return 1;
}
token_array = calloc (1440UL, sizeof (* token_array));
#if DEBUG == 1
yydebug = 1;
#endif
yyfilename = argv[1];
yyin = fopen(yyfilename, "r");
if (eaxhla_init()) {
puts("Initialization failed");
return 1;
}
yyparse();
debug_dump_variables();
if (!has_encountered_error) {
compile();
}
if (was_instruction_array_empty) {
issue_warning("the input did not contain any instructions");
}
deinit();
return has_encountered_error;
}