45 lines
837 B
C
Raw Normal View History

2025-11-22 22:22:43 +01:00
#include <stdio.h>
#include <stdlib.h>
#include "types.h"
#include "tokenizer.h"
#include "interpreter.h"
#include "native_functions.h"
int main(int argc, char **argv) {
if (argc < 2) {
printf("Usage: rc <file.rc>\n");
return 1;
}
FILE *f = fopen(argv[1], "rb");
if (!f) {
printf("Could not open file.\n");
return 1;
}
src_code = malloc(MAX_SRC);
size_t n = fread(src_code, 1, MAX_SRC, f);
src_code[n] = 0;
fclose(f);
register_native_functions();
tokenize(src_code);
scan_functions();
int main_idx = find_func("main", 4);
if (main_idx == -1) {
printf("No main function found.\n");
return 1;
}
pc = funcs[main_idx].entry_point;
memory[sp++] = 0;
memory[sp++] = 0;
ax = 0;
statement();
return 0;
}