-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (33 loc) · 972 Bytes
/
main.cpp
File metadata and controls
43 lines (33 loc) · 972 Bytes
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
#include "Lexer.h"
#include "Parser.h"
#include <iostream>
#include <sstream>
#include <fstream>
using namespace std;
int main(int argc, char** argv) {
// Check command line arguments
if (argc != 2) {
cout << "usage: " << argv[0] << " input_file" << endl;
return 1;
}
// Open file
string fileName = argv[1];
ifstream inputFile(fileName);
if (!inputFile.is_open()) {
cout << "File " << fileName << " could not be found or opened." << endl;
return 1;
}
// Read file into string variable "input"
stringstream ss;
ss << inputFile.rdbuf();
string input = ss.str();
Lexer* lexer = new Lexer();
lexer->Run(input);
// Parse the vector of Tokens
Parser* parser = new Parser();
DatalogProgram* datalogProgram = parser->Parse(lexer->GetTokens());
datalogProgram->ToString();
delete parser;
delete lexer;
return 0;
}