Made precondition parsing more robust.

This commit is contained in:
Patrick Lühne 2017-06-17 18:00:58 +02:00
parent 51249fd678
commit 63e15d37e8
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF

View File

@ -4,6 +4,7 @@
#include <pddlparse/detail/parsing/Expressions.h> #include <pddlparse/detail/parsing/Expressions.h>
#include <pddlparse/detail/parsing/Predicate.h> #include <pddlparse/detail/parsing/Predicate.h>
#include <pddlparse/detail/parsing/Unsupported.h> #include <pddlparse/detail/parsing/Unsupported.h>
#include <pddlparse/detail/parsing/Utils.h>
namespace pddl namespace pddl
{ {
@ -78,25 +79,26 @@ std::experimental::optional<ast::Precondition> parsePreconditionBody(Context &co
const auto position = tokenizer.position(); const auto position = tokenizer.position();
tokenizer.expect<std::string>("("); tokenizer.expect<std::string>("(");
tokenizer.skipWhiteSpace();
const auto expressionIdentifierPosition = tokenizer.position(); const auto expressionIdentifierPosition = tokenizer.position();
if (tokenizer.testIdentifierAndSkip("-") if (tokenizer.testIdentifierAndReturn("-")
|| tokenizer.testIdentifierAndSkip("=") || tokenizer.testIdentifierAndReturn("=")
|| tokenizer.testIdentifierAndSkip("*") || tokenizer.testIdentifierAndReturn("*")
|| tokenizer.testIdentifierAndSkip("+") || tokenizer.testIdentifierAndReturn("+")
|| tokenizer.testIdentifierAndSkip("-") || tokenizer.testIdentifierAndReturn("-")
|| tokenizer.testIdentifierAndSkip("/") || tokenizer.testIdentifierAndReturn("/")
|| tokenizer.testIdentifierAndSkip(">") || tokenizer.testIdentifierAndReturn(">")
|| tokenizer.testIdentifierAndSkip("<") || tokenizer.testIdentifierAndReturn("<")
|| tokenizer.testIdentifierAndSkip("=") || tokenizer.testIdentifierAndReturn("=")
|| tokenizer.testIdentifierAndSkip(">=") || tokenizer.testIdentifierAndReturn(">=")
|| tokenizer.testIdentifierAndSkip("<=")) || tokenizer.testIdentifierAndReturn("<="))
{ {
tokenizer.seek(expressionIdentifierPosition);
const auto expressionIdentifier = tokenizer.getIdentifier(); const auto expressionIdentifier = tokenizer.getIdentifier();
tokenizer.expect<std::string>("(");
tokenizer.seek(position); skipSection(tokenizer);
return parseUnsupported(context); return parseUnsupported(context);
} }