diff --git a/liberty/LibertyParser.cc b/liberty/LibertyParser.cc index 446ce30d..f8249300 100644 --- a/liberty/LibertyParser.cc +++ b/liberty/LibertyParser.cc @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -46,15 +47,25 @@ parseLibertyFile(std::string_view filename, std::string fn(filename); gzstream::igzstream stream(fn.c_str()); if (stream.is_open()) { - LibertyParser reader(filename, library_visitor, report); - LibertyScanner scanner(&stream, filename, &reader, report); - LibertyParse parser(&scanner, &reader); - parser.parse(); + parseLibertyFile(stream, filename, library_visitor, report); } else throw FileNotReadable(filename); } +void +parseLibertyFile(std::istream& file_contents, + std::string_view filename, + LibertyGroupVisitor *library_visitor, + Report *report) +{ + + LibertyParser reader(filename, library_visitor, report); + LibertyScanner scanner(&file_contents, filename, &reader, report); + LibertyParse parser(&scanner, &reader); + parser.parse(); +} + LibertyParser::LibertyParser(std::string_view filename, LibertyGroupVisitor *library_visitor, Report *report) : diff --git a/liberty/LibertyParser.hh b/liberty/LibertyParser.hh index de9ec60c..9f0ce4a4 100644 --- a/liberty/LibertyParser.hh +++ b/liberty/LibertyParser.hh @@ -25,6 +25,7 @@ #pragma once #include +#include #include #include #include @@ -280,6 +281,11 @@ public: virtual void visitVariable(LibertyVariable *variable) = 0; }; +void +parseLibertyFile(std::istream& file_contents, + std::string_view filename, + LibertyGroupVisitor *library_visitor, + Report *report); void parseLibertyFile(std::string_view filename, LibertyGroupVisitor *library_visitor,