-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
37 lines (35 loc) · 1.18 KB
/
main.cpp
File metadata and controls
37 lines (35 loc) · 1.18 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
#include "./globals.hh"
#include "./helpers.hh"
#include "./scan.hh"
int main() {
string key;
while (key != "exit") {
string filePath;
token outToken;
cout << "please enter File Path: " << endl;
cin >> filePath;
string text = "";
string textLine = "";
ifstream MyReadFile(filePath);
while (getline(MyReadFile, textLine)) {
text += textLine + "\n";
lines.push_back(textLine + "\n");
}
//getline(cin, input);
limit = text.size();
lineNum = 1; index = 0; isError = false; textBuffer = "";
while (index < limit && !isError) {
outToken = getToken(text, index, limit);
//cout << "got token: "<< index <<" " << limit<< endl;
textBuffer += "\t" + to_string(lineNum) + ": " + getTokenTypeString(outToken.tType) + outToken.tVal + "\n";
// cout <<"stopped at: " <<input[index]<< endl;
}
cout << textBuffer << endl;
textBuffer = "";
MyReadFile.close();
lines.clear();
cout << "type 'exit' to exit else to continue and restart the program" << endl;
cin >> key;
}
return 0;
}