-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.cpp
More file actions
68 lines (53 loc) · 1.63 KB
/
main.cpp
File metadata and controls
68 lines (53 loc) · 1.63 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
#include <iostream>
#include <sstream>
#include "Utils/Utils.h"
#include "./Interpreter/Interpreter.h"
#include <ctime>
using namespace std;
CatalogManager catalogManager;
int main(int argc, char *argv[]) {
catalogManager.initial_catalog();
clock_t start_t, end_t;
switch (argc)
{
case 1: {
Prompt("\n\n\t*** Welcome to MiniSQL System ***\n", green);
string input_string; // get the input string by lines
Interpreter interpreter;
while (interpreter.GetState() != State::QUIT) {
//* print line prompt
if (interpreter.GetState() == State::IDLE)
cout << " >> ";
else
cout << " ";
getline(cin, input_string);
start_t = clock();
bool rst = interpreter.ProcessInput(input_string);
//cout << input_string << endl;
if (rst) {
istringstream ss(input_string);
interpreter.ReadInput(ss);
}
else {
interpreter.SetState(State::IDLE);
}
end_t=clock();
cout<<endl<<"runtime = "<<(double)(end_t-start_t)<<endl;
}
Prompt("\n\t*** Bye ***\n\n", green);
} break;
case 2: {
//Interpreter interpreter;
//string file_path = argv[1];
//if (interpreter.ParseFileInput(file_path)) {
// interpreter.ExecFile(file_path);
//}
//else {
// PromptErr("Execution failed due to some syntax error.");
//}
} break;
default:
PromptErr("[Syntax Error] too much arguments, expect 1 or 2");
return 0;
}
}