Additional checks on input files.

This commit is contained in:
Stefano Sanfilippo 2015-03-10 21:21:54 +01:00
parent f83f3759d3
commit a0a94d13eb

View File

@ -82,6 +82,8 @@ int process(std::string const& suffix, std::function<bool(std::ostream&, Program
sources.push_back(arg); sources.push_back(arg);
} else if (boost::regex_match(arg, MODULE_RE)) { } else if (boost::regex_match(arg, MODULE_RE)) {
modules.push_back(arg); modules.push_back(arg);
} else {
std::cerr << arg + ": file format not recognized. Perhaps you forgot the .mc/.mm extension?" << std::endl;
} }
} }
@ -92,6 +94,11 @@ int process(std::string const& suffix, std::function<bool(std::ostream&, Program
for (std::string const& name: sources) { for (std::string const& name: sources) {
std::ifstream instream(name); std::ifstream instream(name);
if (!instream.good()) {
std::cerr << name + ": cannot open file" << std::endl;
continue;
}
Program program; Program program;
Scanner scanner(&instream); Scanner scanner(&instream);
Parser parser(scanner, program); Parser parser(scanner, program);