2025-09-13 05:09:20 +02:00
|
|
|
#include "bytecode.h"
|
|
|
|
|
#include "value.h"
|
|
|
|
|
#include "vm.h"
|
2025-09-13 23:50:01 +02:00
|
|
|
#include "parser.h"
|
2025-09-13 05:09:20 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2025-09-13 23:50:01 +02:00
|
|
|
int main(int argc, char **argv) {
|
2025-09-13 05:09:20 +02:00
|
|
|
VM vm;
|
|
|
|
|
vm_init(&vm);
|
|
|
|
|
|
2025-09-13 23:50:01 +02:00
|
|
|
// If a script path is provided, parse and run it
|
|
|
|
|
if (argc > 1) {
|
|
|
|
|
const char *path = argv[1];
|
|
|
|
|
Bytecode *bc = parse_file_to_bytecode(path);
|
|
|
|
|
if (!bc) {
|
|
|
|
|
fprintf(stderr, "Failed to compile script: %s\n", path);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
vm_run(&vm, bc);
|
2025-09-13 05:09:20 +02:00
|
|
|
|
2025-09-13 23:50:01 +02:00
|
|
|
// Print captured output for user scripts
|
|
|
|
|
vm_print_output(&vm);
|
|
|
|
|
vm_clear_output(&vm);
|
2025-09-13 05:09:20 +02:00
|
|
|
|
2025-09-13 23:50:01 +02:00
|
|
|
bytecode_free(bc);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-13 05:09:20 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|