Adds stream interface for parseLibertyFile
Signed-off-by: Ethan Mahintorabi <ethanmoon@google.com>
This commit is contained in:
parent
f668dba758
commit
03d08047a8
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <istream>
|
||||
#include <regex>
|
||||
#include <string>
|
||||
|
||||
|
|
@ -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) :
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <istream>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue