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;
|
||||
};
|
||||
|
||||
const auto language = detectLanguage();
|
||||
|
||||
// TODO: get rid of unknown language type, use exception instead
|
||||
if (language == plasp::Language::Type::Unknown)
|
||||
switch (detectLanguage())
|
||||
{
|
||||
case plasp::Language::Type::Automatic:
|
||||
case plasp::Language::Type::Unknown:
|
||||
{
|
||||
logger.log(colorlog::Priority::Error, "unknown input language");
|
||||
std::cout << std::endl;
|
||||
@ -107,7 +107,8 @@ int CommandTranslate::run(int argc, char **argv)
|
||||
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 &location, const auto &warning)
|
||||
@ -121,12 +122,16 @@ int CommandTranslate::run(int argc, char **argv)
|
||||
auto normalizedDescription = pddl::normalize(std::move(description));
|
||||
const auto translator = plasp::pddl::TranslatorASP(std::move(normalizedDescription), logger.outputStream());
|
||||
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 translator = plasp::sas::TranslatorASP(description, logger.outputStream());
|
||||
translator.translate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (const tokenize::TokenizerException &e)
|
||||
|
Reference in New Issue
Block a user