Refactored “translate” command.
This commit is contained in:
parent
c3b6d6939f
commit
b99e7c198a
@ -96,10 +96,10 @@ int CommandTranslate::run(int argc, char **argv)
|
|||||||
return parserOptions.language;
|
return parserOptions.language;
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto language = detectLanguage();
|
switch (detectLanguage())
|
||||||
|
{
|
||||||
// TODO: get rid of unknown language type, use exception instead
|
case plasp::Language::Type::Automatic:
|
||||||
if (language == plasp::Language::Type::Unknown)
|
case plasp::Language::Type::Unknown:
|
||||||
{
|
{
|
||||||
logger.log(colorlog::Priority::Error, "unknown input language");
|
logger.log(colorlog::Priority::Error, "unknown input language");
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
@ -107,7 +107,8 @@ int CommandTranslate::run(int argc, char **argv)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (language == plasp::Language::Type::PDDL)
|
// TODO: get rid of unknown language type, use exception instead
|
||||||
|
case plasp::Language::Type::PDDL:
|
||||||
{
|
{
|
||||||
const auto logWarning =
|
const auto logWarning =
|
||||||
[&](const auto &location, const auto &warning)
|
[&](const auto &location, const auto &warning)
|
||||||
@ -121,12 +122,16 @@ int CommandTranslate::run(int argc, char **argv)
|
|||||||
auto normalizedDescription = pddl::normalize(std::move(description));
|
auto normalizedDescription = pddl::normalize(std::move(description));
|
||||||
const auto translator = plasp::pddl::TranslatorASP(std::move(normalizedDescription), logger.outputStream());
|
const auto translator = plasp::pddl::TranslatorASP(std::move(normalizedDescription), logger.outputStream());
|
||||||
translator.translate();
|
translator.translate();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (language == plasp::Language::Type::SAS)
|
|
||||||
|
case plasp::Language::Type::SAS:
|
||||||
{
|
{
|
||||||
const auto description = plasp::sas::Description::fromTokenizer(std::move(tokenizer));
|
const auto description = plasp::sas::Description::fromTokenizer(std::move(tokenizer));
|
||||||
const auto translator = plasp::sas::TranslatorASP(description, logger.outputStream());
|
const auto translator = plasp::sas::TranslatorASP(description, logger.outputStream());
|
||||||
translator.translate();
|
translator.translate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const tokenize::TokenizerException &e)
|
catch (const tokenize::TokenizerException &e)
|
||||||
|
Reference in New Issue
Block a user