Requiring goal to contain only one statement.
Previously, the parser read the first statement of the goal as its precondition, but didn’t check that it was properly terminated with a closing parenthesis. This allowed arbitrary text to be included within the goal description without error, which was incorrect. This commit fixes this issue and adds a corresponding unit test.
This commit is contained in:
parent
a1a80332ca
commit
010e7bf41e
@ -283,6 +283,7 @@ void ProblemParser::parseGoalSection(ast::Problem &problem)
|
|||||||
VariableStack variableStack;
|
VariableStack variableStack;
|
||||||
|
|
||||||
problem.goal = parsePrecondition(m_context, astContext, variableStack);
|
problem.goal = parsePrecondition(m_context, astContext, variableStack);
|
||||||
|
tokenizer.expect<std::string>(")");
|
||||||
|
|
||||||
skipSection(tokenizer);
|
skipSection(tokenizer);
|
||||||
}
|
}
|
||||||
|
@ -84,4 +84,13 @@ TEST_CASE("[PDDL parser issues] Check past issues", "[PDDL parser issues]")
|
|||||||
|
|
||||||
CHECK(!containsInvalidFact);
|
CHECK(!containsInvalidFact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check that goal contains just one precondition and is correctly terminated by “)”
|
||||||
|
SECTION("goal may contain only one precondition")
|
||||||
|
{
|
||||||
|
const auto domainFile = fs::path("data") / "issues" / "issue-11.pddl";
|
||||||
|
context.tokenizer.read(domainFile);
|
||||||
|
|
||||||
|
CHECK_THROWS(pddl::parseDescription(context));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
15
tests/data/issues/issue-11.pddl
Normal file
15
tests/data/issues/issue-11.pddl
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
; tests that “imply” statements in preconditions are correctly reduced
|
||||||
|
(define (domain test-normalization)
|
||||||
|
(:predicates
|
||||||
|
(test-predicate-0))
|
||||||
|
)
|
||||||
|
|
||||||
|
(define (problem test-normalization)
|
||||||
|
(:domain test-normalization)
|
||||||
|
|
||||||
|
(:init
|
||||||
|
(test-predicate-0))
|
||||||
|
|
||||||
|
(:goal
|
||||||
|
(test-predicate-0)
|
||||||
|
(error)))
|
Reference in New Issue
Block a user