-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyntaxMain.cpp
More file actions
56 lines (49 loc) · 1.21 KB
/
Copy pathsyntaxMain.cpp
File metadata and controls
56 lines (49 loc) · 1.21 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
//Koby Yoshida
#include <iostream>
#include <fstream>
#include "Syntax.h"
#include "syntaxGenStack.h"
#include "fileio.h"
using namespace std;
int main(int argc, char **argv){
string filePath;
if (argc != 2) { //Checks for valid command line arguments and saves argument to filePath variable
cerr << "Incorrect number of arguments." << endl;
return 0;
}
else {
filePath = argv[1];
}
syntaxGenStack<char> stack(100);
Syntax checker;
fileio io;
while(true){
//beginning of file input
//ifstream in;
io.openFile(filePath);
bool check = checker.checking(io.in, stack);
io.closeFile();
if(check){
cout << "Found no errors. " << endl;
}
char answer;
//this part checks if you want to run another file
cout << "Would you like to run another file? (Enter 'y' or 'n') " << endl;
cin >> answer;
if(answer == 'y'){
cout << "Enter the name of your file. ";
cin >> filePath;
}
else if (answer = 'n'){
break;
}
else{
cout << "Invalid entry. "<< endl;
break;
}
}
//4. report if the syntax is okay or if an error has occurred
//done in checking
//5. report the problem if there is one
//done in checking
}