|
|
@ -1,27 +1,29 @@ |
|
|
|
#include <fstream>
|
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "brainfuck.hpp"
|
|
|
|
#include "error.hpp"
|
|
|
|
#include "lex.hpp"
|
|
|
|
#include "read.hpp"
|
|
|
|
|
|
|
|
using namespace std; |
|
|
|
std::string getFile(std::string filename) { |
|
|
|
std::ifstream file{filename.c_str()}; |
|
|
|
std::stringstream ss; |
|
|
|
ss << file.rdbuf(); |
|
|
|
return ss.str(); |
|
|
|
} |
|
|
|
|
|
|
|
int main(int argc, char* argv[]) { |
|
|
|
std::vector<string> argList; |
|
|
|
for (int i = 0; i < argc; i++) { |
|
|
|
argList.push_back(argv[i]); |
|
|
|
std::vector<std::string> args{argv + 1, argv + argc}; |
|
|
|
if (args.size() == 0) { |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
if (argc == 2) { // must have only 1 arg: file
|
|
|
|
Reader r(argList[1]); |
|
|
|
Lexer lex(r.getFile()); |
|
|
|
Lexer lex{getFile(args[0])}; |
|
|
|
|
|
|
|
vector<OpCode> v = lex.lexCode(); |
|
|
|
std::vector<OpCode> v = lex.lexCode(); // this works, yay
|
|
|
|
|
|
|
|
return 0; |
|
|
|
} else { |
|
|
|
return 1; |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |