-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
81 lines (65 loc) · 2.26 KB
/
Copy pathmain.cpp
File metadata and controls
81 lines (65 loc) · 2.26 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include "Scanner/Scanner.h"
#include "Scanner/Information.h"
#include "Scanner/Token.h"
#include <iostream>
#include <time.h> // For measuring the compilation time
#include "Scanner/t_const.h"
//#include "Parser/Parser.h"
#include "Container/ObjectContainer.h"
#include "IO/ConsoleOutBuffer.h"
#include "IO/ThreadFileOutBuffer.h"
#include "IO/ThreadInBuffer.h"
#include "IO/InBuffer.h"
//TEST
#include "Parser/ListT.h"
#include "Parser/PARSER_NEW.h"
using std::cout;
using std::endl;
using std::cerr;
int main(int argc, char **argv) {
if (argc < 3) {
cout << "Usage: hskac <in:source-file> <out:interpreter-file>" << endl;
return 1;
} else {
cout << "Running hskac..." << endl << "\n Input File : " << argv[1] << endl << " Output File: " << argv[2] << endl << endl;
}
clock_t start, end;
start = clock();
// create the set of keywords
const char* keywords[] = {"print","read","int","while","if","else"};
ObjectContainer<Information>* IOC = new ObjectContainer<Information>(512);
InBuffer* inBuf = new ThreadInBuffer(argv[1]);
// InBuffer* inBuf = new ThreadInBuffer("in.txt");
OutBuffer* out = new ThreadFileOutBuffer(argv[2]);
// OutBuffer* out = new ThreadFileOutBuffer("out.txt");
Scanner* scanner = new Scanner(IOC, inBuf, keywords, 6);
// Parser* parser = new Parser(scanner, out);
// TEST START
// int pE, tE;
// ListT<Node>* testList = new ListT<Node>();
// ProgNEW* pr1 = new ProgNEW(scanner, out, tE, pE);
// DeclsNEW* pr2 = new DeclsNEW(scanner, out, tE, pE);
// DeclNEW* pr3 = new DeclNEW(scanner, out, tE, pE);
// StatementsNEW* pr4 = new StatementsNEW(scanner, out, tE, pE);
// testList->append(pr1);
// testList->append(pr2);
// testList->append(pr3);
// testList->append(pr4);
// testList->print();
// delete testList;
// return 1;
// TEST END
ParserNEW *parser = new ParserNEW(scanner, out);
end = clock();
if(!parser->getParseErrors() && !parser->getTypeErrors())
cout << "Compilation completed" << endl << "Used time: " << (double)(end-start)/CLOCKS_PER_SEC << " s" << endl;
else
cout << "Compilation failed" << endl << "Used time: " << (double)(end-start)/CLOCKS_PER_SEC << " s" << endl;
// clean everything
delete inBuf;
delete out;
delete scanner;
delete IOC;
delete parser;
return 0;
}