-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
45 lines (37 loc) · 1.26 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
// Name: Jevan Smith
// Assignment: Project03
// Date: April 29, 2019
#include <iostream>
#include <vector>
#include "Token.hpp"
#include "Tokenizer.hpp"
#include "Parser.hpp"
#include "TypeDescriptor.hpp"
int main(int argc, char *argv[]) {
if( argc != 2) {
std::cout << "usage: " << argv[0] << " nameOfAnInputFile\n";
exit(1);
}
std::ifstream inputStream;
inputStream.open(argv[1], std::ios::in);
if( ! inputStream.is_open()) {
std::cout << "Unable top open " << argv[1] << ". Terminating...";
perror("Error when attempting to open the input file.");
exit(2);
}
Tokenizer tokenizer(inputStream);
Parser parser(tokenizer);
Statements *statements = parser.statements();
SymTab symTab;
/*std::cout << std::endl;
std::cout << "--------------------------------" << std::endl;
std::cout << "[MESSAGE] Starting print: " << std::endl;
std::cout << "--------------------------------" << std::endl;
statements->print();*/
std::cout << std::endl;
std::cout << "--------------------------------" << std::endl;
std::cout << "[MESSAGE] Program Output: " << std::endl;
std::cout << "--------------------------------" << std::endl;
statements->evaluate(symTab);
return 0;
}