-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
38 lines (31 loc) · 870 Bytes
/
main.cpp
File metadata and controls
38 lines (31 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include "preprocessing/preprocessing.h"
#include "io/io.h"
#include "utils.h"
#include "parser.h"
#include "executor.h"
int main(int argc, char* argv[]) {
/*
We expect a single argument which is the path to a *.sv (stack-vm) file
containing the instructions to execute.
*/
if (argc != 2) {
std::cerr << "Usage ./stack_vm <NAME>.sv" << std::endl;
return -1;
}
/*
We store the instructions in the following int array.
*/
int program[256];
initialize_int_array(program, 256);
std::vector<std::string> code;
if (!load_program(argv[1], code)) {
std::cerr << "Failed to load program!\n" << std::flush;
return -1;
}
code = remove_comments(code);
parse_program(code, program);
StackExecutor executor(program);
executor.execute();
return 0;
}