Added “domain-axioms” as an ignored requirement to increase compatibility.

This commit is contained in:
Patrick Lühne 2017-06-15 23:58:11 +02:00
parent 216decafc1
commit 1e77a6b043
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF
4 changed files with 19 additions and 22 deletions

View File

@ -15,7 +15,7 @@ namespace detail
//
////////////////////////////////////////////////////////////////////////////////////////////////////
ast::Requirement parseRequirement(Context &context);
std::experimental::optional<ast::Requirement> parseRequirement(Context &context);
const char *toString(const ast::Requirement &requirement);
////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -172,7 +172,10 @@ void DomainParser::parseRequirementSection(ast::Domain &domain)
{
tokenizer.expect<std::string>(":");
domain.requirements.emplace_back(parseRequirement(m_context));
const auto requirement = parseRequirement(m_context);
if (requirement)
domain.requirements.emplace_back(requirement.value());
tokenizer.skipWhiteSpace();
}

View File

@ -183,7 +183,10 @@ void ProblemParser::parseRequirementSection(ast::Problem &problem)
{
tokenizer.expect<std::string>(":");
problem.requirements.emplace_back(parseRequirement(m_context));
const auto requirement = parseRequirement(m_context);
if (requirement)
problem.requirements.emplace_back(requirement.value());
tokenizer.skipWhiteSpace();
}

View File

@ -51,34 +51,25 @@ static const RequirementNameMap requirementNameMap =
{"preferences", ast::Requirement::Preferences},
{"constraints", ast::Requirement::Constraints},
{"action-costs", ast::Requirement::ActionCosts},
{"goal-utilities", ast::Requirement::GoalUtilities},
};
////////////////////////////////////////////////////////////////////////////////////////////////////
ast::Requirement parseRequirement(Tokenizer &tokenizer)
{
const auto requirementName = tokenizer.getIdentifier();
const auto matchingRequirement = requirementNameMap.find(requirementName.c_str());
if (matchingRequirement == requirementNameMap.cend())
throw ParserException(tokenizer.location(), "unknown PDDL requirement “" + requirementName + "");
return matchingRequirement->second;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
ast::Requirement parseRequirement(Context &context)
std::experimental::optional<ast::Requirement> parseRequirement(Context &context)
{
auto &tokenizer = context.tokenizer;
auto requirement = parseRequirement(tokenizer);
const auto requirementName = tokenizer.getIdentifier();
if (requirement == ast::Requirement::GoalUtilities)
context.warningCallback(tokenizer.location(), "requirement “goal-utilities” is not part of the PDDL 3.1 specification");
const auto matchingRequirement = requirementNameMap.find(requirementName.c_str());
return requirement;
if (matchingRequirement != requirementNameMap.cend())
return matchingRequirement->second;
if (requirementName == "goal-utilities" || requirementName == "domain-axioms")
context.warningCallback(tokenizer.location(), "ignoring requirement “" + requirementName + "”, which is not part of the PDDL 3.1 specification");
return std::experimental::nullopt;
}
////////////////////////////////////////////////////////////////////////////////////////////////////