Skip to content

Commit

Permalink
(Rosebud) Rosetta generator still produces output even without input
Browse files Browse the repository at this point in the history
* This is necessary in order to set up new, empty directories of
  Rosebud input.

RPM-357
  • Loading branch information
matzke1 committed Apr 21, 2023
1 parent cd09d41 commit 8389481
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Rosebud/Ast.C
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ File::instance(const std::string &name) {
std::ifstream test(name.c_str());
if (!test) {
message(FATAL, "unable to open file for reading: \"" + name + "\"");
exit(1);
return {};
} else {
return Ptr(new File(name));
}
Expand Down
16 changes: 10 additions & 6 deletions src/Rosebud/rosebud.C
Original file line number Diff line number Diff line change
Expand Up @@ -901,9 +901,12 @@ parseClassDefinition(const Ast::File::Ptr &file, Ast::CppStack::Stack &runningCp
return c;
}

static void
parseFile(const Ast::File::Ptr &file) {
ASSERT_not_null(file);
static Ast::File::Ptr
parseFile(const std::string &fileName) {
auto file = Ast::File::instance(fileName);
if (!file)
return {};

size_t filePos = 0;
Ast::CppStack::Stack runningCppStack;
std::vector<Token> nestingStack;
Expand Down Expand Up @@ -937,6 +940,8 @@ parseFile(const Ast::File::Ptr &file) {
// Warn about file problems
if (file->classes.empty())
message(WARN, file, "file contains to class definitions");

return file;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -958,9 +963,8 @@ int main(int argc, char *argv[]) {
// Parse the input files to produce the AST
auto project = Ast::Project::instance();
for (const std::string &arg: args) {
auto file = Ast::File::instance(arg);
project->files.push_back(file);
parseFile(file);
if (auto file = parseFile(arg))
project->files.push_back(file);
}

// Additional warnings that we can't check until all the files are parsed
Expand Down

0 comments on commit 8389481

Please sign in to comment.