Allowing “at” as a predicate name even though it is an expression identifier.
This commit is contained in:
@@ -26,8 +26,7 @@ std::experimental::optional<ast::Fact> parseFact(Context &context, ASTContext &a
|
||||
tokenizer.expect<std::string>("(");
|
||||
tokenizer.skipWhiteSpace();
|
||||
|
||||
if (tokenizer.testIdentifierAndReturn("=")
|
||||
|| tokenizer.testIdentifierAndReturn("at"))
|
||||
if (tokenizer.testIdentifierAndReturn("="))
|
||||
{
|
||||
tokenizer.seek(position);
|
||||
return parseUnsupported(context);
|
||||
@@ -39,12 +38,20 @@ std::experimental::optional<ast::Fact> parseFact(Context &context, ASTContext &a
|
||||
std::experimental::optional<ast::Fact> fact;
|
||||
|
||||
if ((fact = parseNot<ast::Fact>(context, astContext, variableStack, parseAtomicFormula))
|
||||
|| (fact = parseAtomicFormula(context, astContext, variableStack)))
|
||||
|| (fact = parseAtomicFormula(context, astContext, variableStack)))
|
||||
{
|
||||
return std::move(fact.value());
|
||||
}
|
||||
|
||||
return parseAtomicFormula(context, astContext, variableStack);
|
||||
// Test for “at” expressions only now to allow “at” as a predicate name
|
||||
// TODO: allow this in compatibility mode only?
|
||||
if (tokenizer.testIdentifierAndReturn("at"))
|
||||
{
|
||||
tokenizer.seek(position);
|
||||
return parseUnsupported(context);
|
||||
}
|
||||
|
||||
return std::experimental::nullopt;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@@ -60,4 +60,30 @@ TEST_CASE("[PDDL parser issues] Check past issues", "[PDDL parser issues]")
|
||||
context.tokenizer.read(domainFile);
|
||||
CHECK_THROWS(pddl::parseDescription(context));
|
||||
}
|
||||
|
||||
// Check that “at” is allowed as a predicate name and not exclusively for “at” expressions
|
||||
SECTION("“at” as predicate name")
|
||||
{
|
||||
const auto domainFile = fs::path("data") / "issues" / "issue-10.pddl";
|
||||
context.tokenizer.read(domainFile);
|
||||
|
||||
const auto description = pddl::parseDescription(context);
|
||||
|
||||
REQUIRE(description.problem);
|
||||
|
||||
const auto &problem = description.problem.value();
|
||||
const auto &facts = problem->initialState.facts;
|
||||
|
||||
const auto invalidFact = std::find_if(facts.cbegin(), facts.cend(),
|
||||
[](const auto &fact)
|
||||
{
|
||||
return
|
||||
fact.template is<pddl::ast::AtPointer<pddl::ast::Literal>>()
|
||||
|| (fact.template is<pddl::ast::AtomicFormula>() && fact.template get<pddl::ast::AtomicFormula>().template is<pddl::ast::UnsupportedPointer>());
|
||||
});
|
||||
|
||||
const auto containsInvalidFact = (invalidFact != facts.cend());
|
||||
|
||||
CHECK(!containsInvalidFact);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user