-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
35 lines (27 loc) · 667 Bytes
/
Copy pathmain.cpp
File metadata and controls
35 lines (27 loc) · 667 Bytes
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
#include <iostream>
#include "declaration.h"
#include "errors.h"
#include "statements.h"
extern int yylex();
extern int yylineno;
extern FILE* yyin;
ListOfStatements* program;
void yyerror(const std::string& string) {
std::cerr << "Parser error: " << string << std::endl;
exit(COMPILE_ERROR);
}
int main(int argc, char** argv) {
FILE* handle;
if (argc != 2) {
std::cerr << "Usage: " << argv[0] << " filename" << std::endl;
exit(USAGE_ERROR);
}
if (!(handle = fopen(argv[1], "r"))) {
std::cerr << "Can't open file " << argv[1] << std::endl;
exit(FILE_ACCESS_ERROR);
}
yyin = handle;
yyparse();
program->Run();
return 0;
}