-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
51 lines (41 loc) · 1.09 KB
/
Copy pathmain.cpp
File metadata and controls
51 lines (41 loc) · 1.09 KB
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
49
50
51
#include "Lexer.h"
#include "Parser.h"
#include "Interpreter.h"
#include "Database.h"
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
string inputStream = argv[1];
ifstream ifs (inputStream, ifstream::in);
//int index = 1;
//int tupleCount = 1;
char c;
string file;
while(ifs.peek() != EOF){
c = ifs.get();
file += c;
}
Lexer* lexer = new Lexer();
lexer->Run(file);
Parser parse(lexer->getTokenVector());
try{
parse.datalogProgram();
//cout << "Success!" << endl;
//cout << parse.toString();
}
catch(int index){
//cout << "Failure! \n" << lexer->getTokenVector().at(index)->toString() << endl;
}
Datalog datalog = parse.getMyData();
Interpreter interpreter(datalog);
interpreter.evaluateSchemes();
interpreter.evaluateFacts();
interpreter.evaluateAllRules();
cout << endl << "Query Evaluation" << endl;
interpreter.evaluateQueries();
//cout << interpreter.toString();
delete lexer;
return 0;
}