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);
} else if (boost::regex_match(arg, MODULE_RE)) {
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) {
std::ifstream instream(name);
if (!instream.good()) {
std::cerr << name + ": cannot open file" << std::endl;
continue;
}
Program program;
Scanner scanner(&instream);
Parser parser(scanner, program);