From 7de9980c10a6bf2f8c60c660392c83043ba28b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Thu, 31 Aug 2017 18:37:43 +0200 Subject: [PATCH] Refactoring to reuse term parsing code. --- .../src/pddl/detail/parsing/Predicate.cpp | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/lib/pddl/src/pddl/detail/parsing/Predicate.cpp b/lib/pddl/src/pddl/detail/parsing/Predicate.cpp index 4e0f7fc..2de02c3 100644 --- a/lib/pddl/src/pddl/detail/parsing/Predicate.cpp +++ b/lib/pddl/src/pddl/detail/parsing/Predicate.cpp @@ -3,9 +3,7 @@ #include #include #include -#include -#include -#include +#include namespace pddl { @@ -39,29 +37,17 @@ std::experimental::optional parsePredicate(Context &conte // Parse arguments while (tokenizer.currentCharacter() != ')') { - // Parse argument if it is a variable - auto variable = testParsingVariable(context, variableStack); + auto term = parseTerm(context, astContext, variableStack); - if (variable) + if (term) { - arguments.emplace_back(std::move(variable.value())); + arguments.emplace_back(std::move(term.value())); tokenizer.skipWhiteSpace(); continue; } - // Parse argument if it is a constant - auto constant = testParsingConstant(context, astContext); - - if (constant) - { - arguments.emplace_back(std::move(constant.value())); - - tokenizer.skipWhiteSpace(); - continue; - } - - // If argument is neither variable nor constant, this is not a valid predicate + // If the term couldn’t be parsed, this is not a valid predicate tokenizer.seek(previousPosition); return std::experimental::nullopt; }