-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
48 lines (39 loc) · 1.13 KB
/
main.cpp
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
41
42
43
44
45
46
47
48
#include "Lexer.h"
#include "Parser.h"
#include "Interpreter.h"
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, char* argv[]) {
// check command line arguments
if (argc != 2) {
std::cout << "usage: " << argv[0] << " input_file" << endl;
return 1;
}
string fileName = argv[1];
ifstream input(fileName);
if (!input.is_open()) {
cout << "File " << fileName << " could not be found or opened." << endl;
return 1;
}
ifstream inputFile;
inputFile.open(argv[1]);
string inputString;
while (input.peek() != EOF) {
char addC = input.get();
inputString = inputString + addC;
}
auto* lexer = new Lexer();
lexer->Run(inputString);
auto* parser = new Parser(lexer->returnTokens());
parser->Parse();
auto interpreter = new Interpreter(*parser->returnProgram());
interpreter->InterpretSchemes();
interpreter->InterpretFacts();
interpreter->InterpretQueries();
delete parser;
delete lexer;
delete interpreter;
return 0;
}