summaryrefslogtreecommitdiff
path: root/Driver.cc
diff options
context:
space:
mode:
authorNagi5Yeq <wu@x-nagi.com>2020-05-26 00:26:57 +0800
committerNagi5Yeq <wu@x-nagi.com>2020-05-26 00:26:57 +0800
commite83990754f49ec6eba7b9e1a5ff80a6add5de3a1 (patch)
tree6308b4d0afa5bde2de82e7aa034058302cb1d193 /Driver.cc
parent958a811b18aee04e4795cf003fd8e3db00312c91 (diff)
bugfix & test
Diffstat (limited to 'Driver.cc')
-rw-r--r--Driver.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/Driver.cc b/Driver.cc
index 6d557db..a3db940 100644
--- a/Driver.cc
+++ b/Driver.cc
@@ -7,13 +7,18 @@ Driver::Driver(const char* name)
Driver::~Driver() {}
-void Driver::Parse(std::string& filename) {
+std::shared_ptr<ProgramNode> Driver::Parse(std::string& filename) {
location_.initialize(&filename);
if (StartLexer(filename) != 0) {
- return;
+ return nullptr;
}
Parser parser(*this, &context_);
parser.parse();
StopLexer();
+ return root_;
}
+
+void Driver::SetRoot(std::shared_ptr<ProgramNode> root) { root_ = root; }
+
+Context* Driver::GetContext() { return &context_; }
} // namespace pcc