-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver.cpp
45 lines (36 loc) · 844 Bytes
/
driver.cpp
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
#include "driver.hh"
#include "parser.hh"
#include <help/Visitor.h>
Driver::Driver () :
trace_parsing(false),
trace_scanning(false),
location_debug(false),
scanner(*this), parser(scanner, *this) {
}
int Driver::parse (const std::string& f) {
file = f;
// initialize location positions
location.initialize(&file);
scan_begin();
parser.set_debug_level(trace_parsing);
int res = parser();
scan_end();
return res;
}
void Driver::scan_begin () {
scanner.set_debug(trace_scanning);
if (file.empty() || file == "-") {
} else {
stream.open(file);
std::cerr << "File name is " << file << std::endl;
// Restart scanner resetting buffer!
scanner.yyrestart(&stream);
}
}
void Driver::scan_end () {
stream.close();
}
void Driver::execute () {
Visitor visitor;
visitor.visit(program);
}