blob: c39e46966a7e9e04d0da3b9074972299184f95e0 (
plain)
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
39
40
|
#include <iostream>
#include <fstream>
#include <streambuf>
#include <string>
#include "parser.h"
#include "runtime.h"
std::string readFile(std::string& filename) {
std::ifstream t(filename);
std::string str((std::istreambuf_iterator<char>(t)),
(std::istreambuf_iterator<char>()));
return str;
}
int main(int argc, char** argv) {
if (argc != 2) {
std::cout << "Please supply input file name as a parameter." << std::endl;
return 1;
}
std::string filename = std::string(argv[1]);
std::string code = readFile(filename);
std::string valueString;
std::string stdinLine;
while (std::cin >> stdinLine) {
valueString += stdinLine + " ";
}
Parser parser;
std::vector<Token> tokens = parser.parseCode(code);
std::vector<int> values = parser.parseValues(valueString);
parser.printTokens(tokens);
parser.printValues(values);
Runtime runtime;
runtime.run(tokens);
return 0;
}
|