-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cpp
29 lines (26 loc) · 1.03 KB
/
Program.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
#include "Program.h"
#include "statements/Statement.h"
#include "BreakIndicator.h"
#include <ostream>
Program::Program(const std::string& version,
std::vector<std::unique_ptr<Statement>> statements)
: version(version), statements(std::move(statements)) {}
void Program::print(std::ostream& out, int indent) const {
out << "Program(" << std::endl
<< std::string(indent + INDENT_WIDTH, ' ') << "version=\"" << version << "\"," << std::endl
<< std::string(indent + INDENT_WIDTH, ' ') << "statements=[" << std::endl;
for (const auto& statement : statements) {
out << std::string(indent + INDENT_WIDTH * 2, ' ');
statement->print(out, indent + INDENT_WIDTH * 2);
out << "," << std::endl;
}
out << std::string(indent + INDENT_WIDTH, ' ') << "]" << std::endl
<< std::string(indent, ' ') << ")";
}
void Program::exec(Driver& driver) {
try {
for (auto& statement : statements) {
statement->exec(driver);
}
} catch (BreakIndicator b) {}
}