diff --git a/lib/pddlparse/include/pddlparse/ASTForward.h b/lib/pddlparse/include/pddlparse/ASTForward.h index 8a83ce0..762a37f 100644 --- a/lib/pddlparse/include/pddlparse/ASTForward.h +++ b/lib/pddlparse/include/pddlparse/ASTForward.h @@ -150,6 +150,24 @@ class AtomicFormula : public detail::AtomicFormulaT //////////////////////////////////////////////////////////////////////////////////////////////////// +namespace detail +{ +using LiteralT = Variant< + AtomicFormula, + NotPointer>; +} + +class Literal : public detail::LiteralT +{ + Literal() = delete; + + using detail::LiteralT::LiteralT; +}; + +using Literals = std::vector; + +//////////////////////////////////////////////////////////////////////////////////////////////////// + class Precondition; namespace detail @@ -182,9 +200,8 @@ namespace detail { // TODO: add missing types using ConditionalEffectT = Variant< - AtomicFormula, - AndPointer, - NotPointer>; + Literal, + AndPointer>; } class ConditionalEffect : public detail::ConditionalEffectT @@ -234,24 +251,6 @@ class Type : public detail::TypeT //////////////////////////////////////////////////////////////////////////////////////////////////// -namespace detail -{ -using LiteralT = Variant< - AtomicFormula, - NotPointer>; -} - -class Literal : public detail::LiteralT -{ - Literal() = delete; - - using detail::LiteralT::LiteralT; -}; - -using Literals = std::vector; - -//////////////////////////////////////////////////////////////////////////////////////////////////// - class Fact; namespace detail diff --git a/lib/pddlparse/src/pddlparse/detail/parsing/Effect.cpp b/lib/pddlparse/src/pddlparse/detail/parsing/Effect.cpp index 9dcaaee..7b927e1 100644 --- a/lib/pddlparse/src/pddlparse/detail/parsing/Effect.cpp +++ b/lib/pddlparse/src/pddlparse/detail/parsing/Effect.cpp @@ -20,7 +20,7 @@ namespace detail std::experimental::optional parseEffectBody(Context &context, ASTContext &astContext, VariableStack &variableStack); std::experimental::optional parseConditionalEffect(Context &context, ASTContext &astContext, VariableStack &variableStack); -std::experimental::optional parseConditionalEffectBody(Context &context, ASTContext &astContext, VariableStack &variableStack); +std::experimental::optional parseConditionalEffectBody(Context &context, ASTContext &astContext, VariableStack &variableStack); //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -95,7 +95,7 @@ std::experimental::optional parseConditionalEffect(Conte std::experimental::optional conditionalEffect; - if ((conditionalEffect = parseAnd(context, astContext, variableStack, parseConditionalEffectBody))) + if ((conditionalEffect = parseAnd(context, astContext, variableStack, parseConditionalEffectBody))) return std::move(conditionalEffect.value()); return parseConditionalEffectBody(context, astContext, variableStack); @@ -103,7 +103,7 @@ std::experimental::optional parseConditionalEffect(Conte //////////////////////////////////////////////////////////////////////////////////////////////////// -std::experimental::optional parseConditionalEffectBody(Context &context, ASTContext &astContext, VariableStack &variableStack) +std::experimental::optional parseConditionalEffectBody(Context &context, ASTContext &astContext, VariableStack &variableStack) { auto &tokenizer = context.tokenizer; @@ -130,12 +130,12 @@ std::experimental::optional parseConditionalEffectBody(C tokenizer.seek(position); // Now, test supported expressions - std::experimental::optional conditionalEffect; + std::experimental::optional literal; - if ((conditionalEffect = parseNot(context, astContext, variableStack, parseAtomicFormula)) - || (conditionalEffect = parseAtomicFormula(context, astContext, variableStack))) + if ((literal = parseNot(context, astContext, variableStack, parseAtomicFormula)) + || (literal = parseAtomicFormula(context, astContext, variableStack))) { - return std::move(conditionalEffect.value()); + return std::move(literal.value()); } tokenizer.seek(expressionIdentifierPosition); diff --git a/lib/pddlparse/tests/TestOfficialPDDLInstances.cpp b/lib/pddlparse/tests/TestOfficialPDDLInstances.cpp index 9b85721..93f70c3 100644 --- a/lib/pddlparse/tests/TestOfficialPDDLInstances.cpp +++ b/lib/pddlparse/tests/TestOfficialPDDLInstances.cpp @@ -358,7 +358,7 @@ TEST_CASE("[PDDL instances] The official PDDL instances are parsed correctly", " const auto &effectWhen4 = effectAnd->arguments[4].get>(); // TODO: check name of declaration CHECK(effectWhen4->argumentLeft.get>()->argument.get().is()); - CHECK(effectWhen4->argumentRight.get().is()); + CHECK(effectWhen4->argumentRight.get().get().is()); const auto &effectForAll5 = effectAnd->arguments[5].get>(); REQUIRE(effectForAll5->parameters.size() == 1); CHECK(effectForAll5->parameters[0]->name == "oldsurface"); @@ -366,7 +366,7 @@ TEST_CASE("[PDDL instances] The official PDDL instances are parsed correctly", " const auto &effectForAll5When = effectForAll5->argument.get>(); // TODO: check name of declaration CHECK(effectForAll5When->argumentLeft.get().is()); - CHECK(effectForAll5When->argumentRight.get>()->argument.get().is()); + CHECK(effectForAll5When->argumentRight.get().get>()->argument.is()); const auto &effectForAll6 = effectAnd->arguments[6].get>(); REQUIRE(effectForAll6->parameters.size() == 1); CHECK(effectForAll6->parameters[0]->name == "oldpaint"); @@ -378,6 +378,6 @@ TEST_CASE("[PDDL instances] The official PDDL instances are parsed correctly", " const auto &effectForAll9When = effectForAll9->argument.get>(); // TODO: check name of declaration CHECK(effectForAll9When->argumentLeft.get().is()); - CHECK(effectForAll9When->argumentRight.get>()->argument.get().is()); + CHECK(effectForAll9When->argumentRight.get().get>()->argument.is()); } }