-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
88 lines (87 loc) · 2.31 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
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
82
83
84
85
86
87
88
#include "includes/token.h"
#include "includes/io.h"
#include "includes/lexing.h"
#include "includes/parsing.h"
#include "includes/exception.h"
#include "includes/IRVisitor.h"
#include "IRNode.h"
string rawString;
int autoMode = 0;
extern node * ASTRoot;
extern symbolTable* rootTable;
extern Module *IRRoot;
void autoTest()
{
cout << "============autoTest Mode================" << endl;
string instr = "";
string outstr = "";
for (int i = 1; i <= 30; i++)
{
token::tokens.clear();
ASTRoot= nullptr;
rootTable= nullptr;
IRRoot= nullptr;
instr = "A/testfile" + to_string(i) + ".txt";
outstr = "A/myoutput" + to_string(i) + ".ll";
rawString = read(instr);
DFA(rawString);
lexingOutput(outstr);
ASTRoot=parsing();
parsingOutput(outstr);
exceptionVisitor();
errorOutput("error.txt");
visitor(outstr);
}
for (int i = 1; i <= 30; i++)
{
token::tokens.clear();
ASTRoot= nullptr;
rootTable= nullptr;
IRRoot= nullptr;
instr = "B/testfile" + to_string(i) + ".txt";
outstr = "B/myoutput" + to_string(i) + ".ll";
rawString = read(instr);
DFA(rawString);
lexingOutput(outstr);
ASTRoot=parsing();
parsingOutput(outstr);
exceptionVisitor();
errorOutput("error.txt");
visitor(outstr);
}
for (int i = 1; i <= 30; i++)
{
token::tokens.clear();
ASTRoot= nullptr;
rootTable= nullptr;
IRRoot= nullptr;
instr = "C/testfile" + to_string(i) + ".txt";
outstr = "C/myoutput" + to_string(i) + ".ll";
rawString = read(instr);
DFA(rawString);
lexingOutput(outstr);
ASTRoot=parsing();
parsingOutput(outstr);
exceptionVisitor();
errorOutput("error.txt");
visitor(outstr);
}
}
int main(int args, char *argv[])
{
if (args > 1 && strcmp(argv[1], "at") == 0)
autoMode = 1;
if (autoMode == 1)
autoTest();
else
{
rawString = read("testfile.txt");
DFA(rawString);
lexingOutput("output.txt");
ASTRoot=parsing();
parsingOutput("output.txt");
exceptionVisitor();
errorOutput("error.txt");
visitor("llvm_ir.txt");
}
}