Simplified plasp application by initializing parser externally.

This commit is contained in:
Patrick Lühne 2016-06-10 00:59:44 +02:00
parent c6dc84f27f
commit 8ef874eb22

View File

@ -61,37 +61,34 @@ int main(int argc, char **argv)
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
plasp::utils::Parser parser;
parser.setCaseSensitive(false);
if (variablesMap.count("input"))
{
const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>();
std::for_each(inputFiles.cbegin(), inputFiles.cend(),
[&](const auto &inputFile)
{
parser.readFile(inputFile);
});
}
else
parser.readStream("std::cin", std::cin);
auto format = variablesMap["format"].as<std::string>(); auto format = variablesMap["format"].as<std::string>();
std::transform(format.begin(), format.end(), format.begin(), ::tolower); std::transform(format.begin(), format.end(), format.begin(), ::tolower);
if (format == "sas") if (format == "sas")
{ {
if (variablesMap.count("input")) const auto sasDescription = plasp::sas::Description::fromParser(std::move(parser));
{ const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription);
const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>(); sasTranslator.translate(std::cout);
const auto sasDescription = plasp::sas::Description::fromFile(inputFiles.front());
const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription);
sasTranslator.translate(std::cout);
}
else
{
const auto sasDescription = plasp::sas::Description::fromStream(std::cin);
const auto sasTranslator = plasp::sas::TranslatorASP(sasDescription);
sasTranslator.translate(std::cout);
}
} }
else if (format == "pddl") else if (format == "pddl")
{ plasp::pddl::Description::fromParser(std::move(parser));
if (variablesMap.count("input"))
{
const auto &inputFiles = variablesMap["input"].as<std::vector<std::string>>();
const auto pddlDescription = plasp::pddl::Description::fromFiles(inputFiles);
}
else
const auto pddlDescription = plasp::pddl::Description::fromStream(std::cin);
//std::cout << pddlDescription << std::endl;
}
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }