-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
57 lines (48 loc) · 1.06 KB
/
Copy pathmain.cpp
File metadata and controls
57 lines (48 loc) · 1.06 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
/* Programming Assignment 3
*
* main.cpp
*
* CS280 - Spring 2024
* parser and interpreter testing program
*/
#include <iostream>
#include <fstream>
#include "parser.cpp"
using namespace std;
int main(int argc, char *argv[])
{
int lineNumber = 1;
istream *in = NULL;
ifstream file;
for( int i=1; i<argc; i++ )
{
string arg = argv[i];
if( in != NULL )
{
cerr << "ONLY ONE FILE NAME ALLOWED" << endl;
return 0;
}
else
{
file.open(arg.c_str());
if( file.is_open() == false )
{
cerr << "CANNOT OPEN " << arg << endl;
return 0;
}
in = &file;
}
}
if(argc == 1)
{
cerr << "Missing File Name." << endl;
return 0;
}
bool status = Prog(*in, lineNumber);
if( !status ){
cout << "\nUnsuccessful Interpretation " << endl << "Number of Errors " << ErrCount() << endl;
}
else{
cout << "\nSuccessful Execution" << endl;
}
}