-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
59 lines (42 loc) · 1.19 KB
/
main.cpp
File metadata and controls
59 lines (42 loc) · 1.19 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
52
53
54
55
56
57
58
#include <iostream>
#include <vector>
#include <sys/time.h>
#include <sys/resource.h>
#include "Token.hpp"
#include "Parser.hpp"
#include "DescriptorFunctions.hpp"
#include "Debug.hpp"
#include "./lex/Lexer.hpp"
#include "./statements/Statement.hpp"
long getMemoryUsage()
{
struct rusage usage;
if(0 == getrusage(RUSAGE_SELF, &usage))
return usage.ru_maxrss; // bytes
else
return 0;
}
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);
}
SymTab symTab = SymTab();
Lexer lex = Lexer(inputStream);
Parser parser(lex);
auto stmts = parser.file_input();
stmts->dumpAST("");
//std::cout << std::endl << std::endl;
stmts->evaluate(symTab);
// std::cout << "Evaluate Done - Dumping Tree" << std::endl;
// std::cout << getMemoryUsage() << std::endl;
// stmts->dumpAST("");
return 0;
}