Refactored “translate” command.
This commit is contained in:
parent
c3b6d6939f
commit
b99e7c198a
@ -96,37 +96,42 @@ 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
|
|
||||||
if (language == plasp::Language::Type::Unknown)
|
|
||||||
{
|
{
|
||||||
logger.log(colorlog::Priority::Error, "unknown input language");
|
case plasp::Language::Type::Automatic:
|
||||||
std::cout << std::endl;
|
case plasp::Language::Type::Unknown:
|
||||||
printHelp();
|
{
|
||||||
return EXIT_FAILURE;
|
logger.log(colorlog::Priority::Error, "unknown input language");
|
||||||
}
|
std::cout << std::endl;
|
||||||
|
printHelp();
|
||||||
|
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)
|
const auto logWarning =
|
||||||
{
|
[&](const auto &location, const auto &warning)
|
||||||
logger.log(colorlog::Priority::Warning, location, warning);
|
{
|
||||||
};
|
logger.log(colorlog::Priority::Warning, location, warning);
|
||||||
|
};
|
||||||
|
|
||||||
auto context = pddl::Context(std::move(tokenizer), logWarning);
|
auto context = pddl::Context(std::move(tokenizer), logWarning);
|
||||||
context.mode = parserOptions.parsingMode;
|
context.mode = parserOptions.parsingMode;
|
||||||
auto description = pddl::parseDescription(context);
|
auto description = pddl::parseDescription(context);
|
||||||
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)
|
}
|
||||||
{
|
|
||||||
const auto description = plasp::sas::Description::fromTokenizer(std::move(tokenizer));
|
case plasp::Language::Type::SAS:
|
||||||
const auto translator = plasp::sas::TranslatorASP(description, logger.outputStream());
|
{
|
||||||
translator.translate();
|
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)
|
catch (const tokenize::TokenizerException &e)
|
||||||
|
Reference in New Issue
Block a user