-
Notifications
You must be signed in to change notification settings - Fork 246
Adds stream interface for parseLibertyFile #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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) | ||
| { | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove blank line here. |
||
| 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) : | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,7 @@ | |
| #pragma once | ||
|
|
||
| #include <functional> | ||
| #include <istream> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| #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, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment here "// Parse Liberty from an in-memory stream.
//
filenameis used only as a label in diagnostic messages;// it need not correspond to a file on disk."
It was a bit confusing to me how file_contents and filename interacted- but once I got it, I think it makes sense to add a one-line explanation.