From 63e15d37e886fe5eb93116aa72d6b76b57b7e776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Sat, 17 Jun 2017 18:00:58 +0200 Subject: [PATCH] Made precondition parsing more robust. --- .../pddlparse/detail/parsing/Precondition.cpp | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/pddlparse/src/pddlparse/detail/parsing/Precondition.cpp b/lib/pddlparse/src/pddlparse/detail/parsing/Precondition.cpp index 53b1686..fbb0586 100644 --- a/lib/pddlparse/src/pddlparse/detail/parsing/Precondition.cpp +++ b/lib/pddlparse/src/pddlparse/detail/parsing/Precondition.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace pddl { @@ -78,25 +79,26 @@ std::experimental::optional parsePreconditionBody(Context &co const auto position = tokenizer.position(); tokenizer.expect("("); + tokenizer.skipWhiteSpace(); const auto expressionIdentifierPosition = tokenizer.position(); - if (tokenizer.testIdentifierAndSkip("-") - || tokenizer.testIdentifierAndSkip("=") - || tokenizer.testIdentifierAndSkip("*") - || tokenizer.testIdentifierAndSkip("+") - || tokenizer.testIdentifierAndSkip("-") - || tokenizer.testIdentifierAndSkip("/") - || tokenizer.testIdentifierAndSkip(">") - || tokenizer.testIdentifierAndSkip("<") - || tokenizer.testIdentifierAndSkip("=") - || tokenizer.testIdentifierAndSkip(">=") - || tokenizer.testIdentifierAndSkip("<=")) + if (tokenizer.testIdentifierAndReturn("-") + || tokenizer.testIdentifierAndReturn("=") + || tokenizer.testIdentifierAndReturn("*") + || tokenizer.testIdentifierAndReturn("+") + || tokenizer.testIdentifierAndReturn("-") + || tokenizer.testIdentifierAndReturn("/") + || tokenizer.testIdentifierAndReturn(">") + || tokenizer.testIdentifierAndReturn("<") + || tokenizer.testIdentifierAndReturn("=") + || tokenizer.testIdentifierAndReturn(">=") + || tokenizer.testIdentifierAndReturn("<=")) { - tokenizer.seek(expressionIdentifierPosition); const auto expressionIdentifier = tokenizer.getIdentifier(); + tokenizer.expect("("); - tokenizer.seek(position); + skipSection(tokenizer); return parseUnsupported(context); }