#include "Interpreter.hpp"
#include <vector>
#include <string>
#include <fstream>
#include <iostream>
#include <exception>
using namespace std;
int main(int argc, char** argv) {
vector<string> args(argv + 1, argv + argc);
for (auto&& arg : args) {
try {
ifstream file(arg);
if (!file) {
cout << "The file " << arg << " could not be opened. Skipping." << endl << endl;
continue;
}
interpreter interpret(file, cout);
interpret.load_commands();
cout << arg << ":" << endl;
interpret.execute_commands();
cout << endl << endl;
}
catch (invalid_argument ex) {
cout << "Syntax error while parsing " << arg << " file." << endl << "Reason: " << ex.what() << endl << endl;
}
catch (runtime_error ex) {
cout << "Runtime error while executing " << arg << " file." << endl << "Reason: " << ex.what() << endl << endl;
}
}
}