diff --git a/include/plasp/pddl/Action.h b/include/plasp/pddl/Action.h index d0b1b94..6836227 100644 --- a/include/plasp/pddl/Action.h +++ b/include/plasp/pddl/Action.h @@ -4,7 +4,7 @@ #include #include -#include +#include #include namespace plasp @@ -26,7 +26,7 @@ class Action public: const std::string &name() const; - const expressions::VariableExpressions ¶meters() const; + const expressions::Variables ¶meters() const; const Expression &precondition() const; const Expression &effect() const; @@ -35,7 +35,7 @@ class Action std::string m_name; - expressions::VariableExpressions m_parameters; + expressions::Variables m_parameters; std::unique_ptr m_precondition; std::unique_ptr m_effect; }; diff --git a/include/plasp/pddl/Expression.h b/include/plasp/pddl/Expression.h index 1d054a7..c7d3d6d 100644 --- a/include/plasp/pddl/Expression.h +++ b/include/plasp/pddl/Expression.h @@ -28,21 +28,21 @@ using Expressions = std::vector; namespace expressions { -class AndExpression; -using AndExpressionPointer = std::unique_ptr; +class And; +using AndPointer = std::unique_ptr; -class NotExpression; -using NotExpressionPointer = std::unique_ptr; +class Not; +using NotPointer = std::unique_ptr; -class OrExpression; -using OrExpressionPointer = std::unique_ptr; +class Or; +using OrPointer = std::unique_ptr; -class PredicateExpression; -using PredicateExpressionPointer = std::unique_ptr; +class Predicate; +using PredicatePointer = std::unique_ptr; -class VariableExpression; -using VariableExpressionPointer = std::unique_ptr; -using VariableExpressions = std::vector; +class Variable; +using VariablePointer = std::unique_ptr; +using Variables = std::vector; } //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -56,12 +56,12 @@ class Expression //////////////////////////////////////////////////////////////////////////////////////////////////// ExpressionPointer parsePreconditionExpression(utils::Parser &parser, Context &context, - const expressions::VariableExpressions ¶meters); + const expressions::Variables ¶meters); ExpressionPointer parseExpression(utils::Parser &parser, Context &context, - const expressions::VariableExpressions ¶meters); + const expressions::Variables ¶meters); ExpressionPointer parseEffectExpression(utils::Parser &parser, Context &context, - const expressions::VariableExpressions ¶meters); + const expressions::Variables ¶meters); //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/include/plasp/pddl/expressions/AndExpression.h b/include/plasp/pddl/expressions/And.h similarity index 53% rename from include/plasp/pddl/expressions/AndExpression.h rename to include/plasp/pddl/expressions/And.h index 2ce7ce6..8a55e18 100644 --- a/include/plasp/pddl/expressions/AndExpression.h +++ b/include/plasp/pddl/expressions/And.h @@ -1,7 +1,7 @@ -#ifndef __PLASP__PDDL__EXPRESSION__AND_EXPRESSION_H -#define __PLASP__PDDL__EXPRESSION__AND_EXPRESSION_H +#ifndef __PLASP__PDDL__EXPRESSION__AND_H +#define __PLASP__PDDL__EXPRESSION__AND_H -#include +#include namespace plasp { @@ -12,33 +12,33 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// AndExpression +// And // //////////////////////////////////////////////////////////////////////////////////////////////////// -class AndExpression: public NAryExpression +class And: public NAry { public: template - static AndExpressionPointer parse(utils::Parser &parser, Context &context, - const VariableExpressions ¶meters, ExpressionParser parseExpression); + static AndPointer parse(utils::Parser &parser, Context &context, + const Variables ¶meters, ExpressionParser parseExpression); public: void accept(ExpressionVisitor &expressionVisitor) const override; private: - AndExpression() = default; + And() = default; }; //////////////////////////////////////////////////////////////////////////////////////////////////// template -AndExpressionPointer AndExpression::parse(utils::Parser &parser, Context &context, - const VariableExpressions ¶meters, ExpressionParser parseExpression) +AndPointer And::parse(utils::Parser &parser, Context &context, + const Variables ¶meters, ExpressionParser parseExpression) { - auto expression = std::make_unique(AndExpression()); + auto expression = std::make_unique(And()); - expression->NAryExpression::parse(parser, context, parameters, parseExpression); + expression->NAry::parse(parser, context, parameters, parseExpression); if (expression->arguments().empty()) throw ConsistencyException("\"and\" expressions should not be empty"); diff --git a/include/plasp/pddl/expressions/NAryExpression.h b/include/plasp/pddl/expressions/NAry.h similarity index 75% rename from include/plasp/pddl/expressions/NAryExpression.h rename to include/plasp/pddl/expressions/NAry.h index 4008ba4..86413dd 100644 --- a/include/plasp/pddl/expressions/NAryExpression.h +++ b/include/plasp/pddl/expressions/NAry.h @@ -1,5 +1,5 @@ -#ifndef __PLASP__PDDL__EXPRESSION__N_ARY_EXPRESSION_H -#define __PLASP__PDDL__EXPRESSION__N_ARY_EXPRESSION_H +#ifndef __PLASP__PDDL__EXPRESSION__N_ARY_H +#define __PLASP__PDDL__EXPRESSION__N_ARY_H #include #include @@ -7,7 +7,7 @@ #include #include -#include +#include #include namespace plasp @@ -19,18 +19,18 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// NAryExpression +// NAry // //////////////////////////////////////////////////////////////////////////////////////////////////// -class NAryExpression: public Expression +class NAry: public Expression { public: const Expressions &arguments() const; protected: template - void parse(utils::Parser &parser, Context &context, const VariableExpressions ¶meters, + void parse(utils::Parser &parser, Context &context, const Variables ¶meters, ExpressionParser parseExpression); private: @@ -40,8 +40,8 @@ class NAryExpression: public Expression //////////////////////////////////////////////////////////////////////////////////////////////////// template -void NAryExpression::parse(utils::Parser &parser, Context &context, - const VariableExpressions ¶meters, ExpressionParser parseExpression) +void NAry::parse(utils::Parser &parser, Context &context, + const Variables ¶meters, ExpressionParser parseExpression) { parser.skipWhiteSpace(); diff --git a/include/plasp/pddl/expressions/NotExpression.h b/include/plasp/pddl/expressions/Not.h similarity index 62% rename from include/plasp/pddl/expressions/NotExpression.h rename to include/plasp/pddl/expressions/Not.h index 982b1d8..86f814a 100644 --- a/include/plasp/pddl/expressions/NotExpression.h +++ b/include/plasp/pddl/expressions/Not.h @@ -1,5 +1,5 @@ -#ifndef __PLASP__PDDL__EXPRESSION__NOT_EXPRESSION_H -#define __PLASP__PDDL__EXPRESSION__NOT_EXPRESSION_H +#ifndef __PLASP__PDDL__EXPRESSION__NOT_H +#define __PLASP__PDDL__EXPRESSION__NOT_H #include #include @@ -13,16 +13,16 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// NotExpression +// Not // //////////////////////////////////////////////////////////////////////////////////////////////////// -class NotExpression: public Expression +class Not: public Expression { public: template - static NotExpressionPointer parse(utils::Parser &parser, Context &context, - const VariableExpressions ¶meters, ExpressionParser parseExpression); + static NotPointer parse(utils::Parser &parser, Context &context, + const Variables ¶meters, ExpressionParser parseExpression); public: void accept(ExpressionVisitor &expressionVisitor) const override; @@ -30,7 +30,7 @@ class NotExpression: public Expression const Expression &argument(); private: - NotExpression() = default; + Not() = default; ExpressionPointer m_argument; }; @@ -38,10 +38,10 @@ class NotExpression: public Expression //////////////////////////////////////////////////////////////////////////////////////////////////// template -NotExpressionPointer NotExpression::parse(utils::Parser &parser, Context &context, - const VariableExpressions ¶meters, ExpressionParser parseExpression) +NotPointer Not::parse(utils::Parser &parser, Context &context, + const Variables ¶meters, ExpressionParser parseExpression) { - auto expression = std::make_unique(NotExpression()); + auto expression = std::make_unique(Not()); parser.skipWhiteSpace(); diff --git a/include/plasp/pddl/expressions/OrExpression.h b/include/plasp/pddl/expressions/Or.h similarity index 53% rename from include/plasp/pddl/expressions/OrExpression.h rename to include/plasp/pddl/expressions/Or.h index 50f34ed..82cdf79 100644 --- a/include/plasp/pddl/expressions/OrExpression.h +++ b/include/plasp/pddl/expressions/Or.h @@ -1,7 +1,7 @@ -#ifndef __PLASP__PDDL__EXPRESSION__OR_EXPRESSION_H -#define __PLASP__PDDL__EXPRESSION__OR_EXPRESSION_H +#ifndef __PLASP__PDDL__EXPRESSION__OR_H +#define __PLASP__PDDL__EXPRESSION__OR_H -#include +#include namespace plasp { @@ -12,33 +12,33 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// OrExpression +// Or // //////////////////////////////////////////////////////////////////////////////////////////////////// -class OrExpression: public NAryExpression +class Or: public NAry { public: template - static OrExpressionPointer parse(utils::Parser &parser, Context &context, - const VariableExpressions ¶meters, ExpressionParser parseExpression); + static OrPointer parse(utils::Parser &parser, Context &context, + const Variables ¶meters, ExpressionParser parseExpression); public: void accept(ExpressionVisitor &expressionVisitor) const override; private: - OrExpression() = default; + Or() = default; }; //////////////////////////////////////////////////////////////////////////////////////////////////// template -OrExpressionPointer OrExpression::parse(utils::Parser &parser, Context &context, - const VariableExpressions ¶meters, ExpressionParser parseExpression) +OrPointer Or::parse(utils::Parser &parser, Context &context, + const Variables ¶meters, ExpressionParser parseExpression) { - auto expression = std::make_unique(OrExpression()); + auto expression = std::make_unique(Or()); - expression->NAryExpression::parse(parser, context, parameters, parseExpression); + expression->NAry::parse(parser, context, parameters, parseExpression); if (expression->arguments().empty()) throw ConsistencyException("\"or\" expressions should not be empty"); diff --git a/include/plasp/pddl/expressions/PredicateExpression.h b/include/plasp/pddl/expressions/Predicate.h similarity index 51% rename from include/plasp/pddl/expressions/PredicateExpression.h rename to include/plasp/pddl/expressions/Predicate.h index 2a30e1a..f5da265 100644 --- a/include/plasp/pddl/expressions/PredicateExpression.h +++ b/include/plasp/pddl/expressions/Predicate.h @@ -1,9 +1,9 @@ -#ifndef __PLASP__PDDL__EXPRESSION__PREDICATE_EXPRESSION_H -#define __PLASP__PDDL__EXPRESSION__PREDICATE_EXPRESSION_H +#ifndef __PLASP__PDDL__EXPRESSION__PREDICATE_H +#define __PLASP__PDDL__EXPRESSION__PREDICATE_H #include #include -#include +#include namespace plasp { @@ -14,26 +14,26 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// PredicateExpression +// Predicate // //////////////////////////////////////////////////////////////////////////////////////////////////// -class PredicateExpression: public Expression +class Predicate: public Expression { public: - static PredicateExpressionPointer parse(std::string name, utils::Parser &parser, - Context &context, const VariableExpressions ¶meters); + static PredicatePointer parse(std::string name, utils::Parser &parser, + Context &context, const Variables ¶meters); public: void accept(ExpressionVisitor &expressionVisitor) const override; - const std::vector &arguments() const; + const std::vector &arguments() const; private: - PredicateExpression() = default; + Predicate() = default; std::string m_name; - std::vector m_arguments; + std::vector m_arguments; }; //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/include/plasp/pddl/expressions/VariableExpression.h b/include/plasp/pddl/expressions/Variable.h similarity index 64% rename from include/plasp/pddl/expressions/VariableExpression.h rename to include/plasp/pddl/expressions/Variable.h index a023036..35caf4d 100644 --- a/include/plasp/pddl/expressions/VariableExpression.h +++ b/include/plasp/pddl/expressions/Variable.h @@ -1,5 +1,5 @@ -#ifndef __PLASP__PDDL__EXPRESSION__VARIABLE_EXPRESSION_H -#define __PLASP__PDDL__EXPRESSION__VARIABLE_EXPRESSION_H +#ifndef __PLASP__PDDL__EXPRESSION__VARIABLE_H +#define __PLASP__PDDL__EXPRESSION__VARIABLE_H #include @@ -12,19 +12,18 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// VariableExpression +// Variable // //////////////////////////////////////////////////////////////////////////////////////////////////// -class VariableExpression: public Expression +class Variable: public Expression { public: - static VariableExpressionPointer parseDeclaration(utils::Parser &parser); + static VariablePointer parseDeclaration(utils::Parser &parser); static void parseTypedDeclaration(utils::Parser &parser, Context &context, - VariableExpressions &variableExpressions); + Variables &variables); - static const VariableExpression *parse(utils::Parser &parser, - const VariableExpressions &variableExpressions); + static const Variable *parse(utils::Parser &parser, const Variables &variables); public: void accept(ExpressionVisitor &expressionVisitor) const override; @@ -38,7 +37,7 @@ class VariableExpression: public Expression void setType(TypePtr type); private: - VariableExpression(); + Variable(); bool m_isDirty; diff --git a/src/plasp/pddl/Action.cpp b/src/plasp/pddl/Action.cpp index a7e6e87..c011298 100644 --- a/src/plasp/pddl/Action.cpp +++ b/src/plasp/pddl/Action.cpp @@ -37,7 +37,7 @@ Action &Action::parseDeclaration(utils::Parser &parser, Context &context) // Read parameters while (parser.currentCharacter() != ')') { - expressions::VariableExpression::parseTypedDeclaration(parser, context, action->m_parameters); + expressions::Variable::parseTypedDeclaration(parser, context, action->m_parameters); parser.skipWhiteSpace(); } @@ -74,7 +74,7 @@ const std::string &Action::name() const //////////////////////////////////////////////////////////////////////////////////////////////////// -const expressions::VariableExpressions &Action::parameters() const +const expressions::Variables &Action::parameters() const { return m_parameters; } diff --git a/src/plasp/pddl/Expression.cpp b/src/plasp/pddl/Expression.cpp index 85dd902..234cdd1 100644 --- a/src/plasp/pddl/Expression.cpp +++ b/src/plasp/pddl/Expression.cpp @@ -2,10 +2,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include namespace plasp @@ -20,11 +20,11 @@ namespace pddl //////////////////////////////////////////////////////////////////////////////////////////////////// ExpressionPointer parseExpressionContent(const std::string &expressionIdentifier, - utils::Parser &parser, Context &context, const expressions::VariableExpressions ¶meters); + utils::Parser &parser, Context &context, const expressions::Variables ¶meters); ExpressionPointer parseEffectBodyExpressionContent(const std::string &expressionIdentifier, - utils::Parser &parser, Context &context, const expressions::VariableExpressions ¶meters); -ExpressionPointer parsePredicateExpression(utils::Parser &parser, Context &context, - const expressions::VariableExpressions ¶meters); + utils::Parser &parser, Context &context, const expressions::Variables ¶meters); +ExpressionPointer parsePredicate(utils::Parser &parser, Context &context, + const expressions::Variables ¶meters); //////////////////////////////////////////////////////////////////////////////////////////////////// @@ -36,7 +36,7 @@ void throwUnsupported(const utils::Parser &parser, const std::string &expression //////////////////////////////////////////////////////////////////////////////////////////////////// ExpressionPointer parsePreconditionExpression(utils::Parser &parser, Context &context, - const expressions::VariableExpressions ¶meters) + const expressions::Variables ¶meters) { parser.expect("("); @@ -46,7 +46,7 @@ ExpressionPointer parsePreconditionExpression(utils::Parser &parser, Context &co if (expressionIdentifier == "and") { - expression = expressions::AndExpression::parse(parser, context, parameters, + expression = expressions::And::parse(parser, context, parameters, parsePreconditionExpression); } else if (expressionIdentifier == "forall" @@ -65,7 +65,7 @@ ExpressionPointer parsePreconditionExpression(utils::Parser &parser, Context &co //////////////////////////////////////////////////////////////////////////////////////////////////// ExpressionPointer parseExpression(utils::Parser &parser, Context &context, - const expressions::VariableExpressions ¶meters) + const expressions::Variables ¶meters) { parser.expect("("); @@ -81,18 +81,18 @@ ExpressionPointer parseExpression(utils::Parser &parser, Context &context, //////////////////////////////////////////////////////////////////////////////////////////////////// ExpressionPointer parseExpressionContent(const std::string &expressionIdentifier, - utils::Parser &parser, Context &context, const expressions::VariableExpressions ¶meters) + utils::Parser &parser, Context &context, const expressions::Variables ¶meters) { parser.skipWhiteSpace(); ExpressionPointer expression; if (expressionIdentifier == "and") - expression = expressions::AndExpression::parse(parser, context, parameters, parseExpression); + expression = expressions::And::parse(parser, context, parameters, parseExpression); else if (expressionIdentifier == "or") - expression = expressions::OrExpression::parse(parser, context, parameters, parseExpression); + expression = expressions::Or::parse(parser, context, parameters, parseExpression); else if (expressionIdentifier == "not") - expression = expressions::NotExpression::parse(parser, context, parameters, parseExpression); + expression = expressions::Not::parse(parser, context, parameters, parseExpression); else if (expressionIdentifier == "imply" || expressionIdentifier == "exists" || expressionIdentifier == "forall" @@ -121,7 +121,7 @@ ExpressionPointer parseExpressionContent(const std::string &expressionIdentifier // If predicate exists, parse it if (match != context.predicates.cend()) - expression = expressions::PredicateExpression::parse(expressionIdentifier, parser, context, parameters); + expression = expressions::Predicate::parse(expressionIdentifier, parser, context, parameters); else throw utils::ParserException(parser.row(), parser.column(), "Expression \"" + expressionIdentifier + "\" not allowed in this context"); } @@ -132,7 +132,7 @@ ExpressionPointer parseExpressionContent(const std::string &expressionIdentifier //////////////////////////////////////////////////////////////////////////////////////////////////// ExpressionPointer parseEffectExpression(utils::Parser &parser, Context &context, - const expressions::VariableExpressions ¶meters) + const expressions::Variables ¶meters) { parser.expect("("); @@ -141,7 +141,7 @@ ExpressionPointer parseEffectExpression(utils::Parser &parser, Context &context, ExpressionPointer expression; if (expressionIdentifier == "and") - expression = expressions::AndExpression::parse(parser, context, parameters, parseEffectExpression); + expression = expressions::And::parse(parser, context, parameters, parseEffectExpression); else if (expressionIdentifier == "forall" || expressionIdentifier == "when") { @@ -158,12 +158,12 @@ ExpressionPointer parseEffectExpression(utils::Parser &parser, Context &context, //////////////////////////////////////////////////////////////////////////////////////////////////// ExpressionPointer parseEffectBodyExpressionContent(const std::string &expressionIdentifier, - utils::Parser &parser, Context &context, const expressions::VariableExpressions ¶meters) + utils::Parser &parser, Context &context, const expressions::Variables ¶meters) { ExpressionPointer expression; if (expressionIdentifier == "not") - expression = expressions::NotExpression::parse(parser, context, parameters, parsePredicateExpression); + expression = expressions::Not::parse(parser, context, parameters, parsePredicate); else if (expressionIdentifier == "=" || expressionIdentifier == "assign" || expressionIdentifier == "scale-up" @@ -184,7 +184,7 @@ ExpressionPointer parseEffectBodyExpressionContent(const std::string &expression // If predicate exists, parse it if (match != context.predicates.cend()) - expression = expressions::PredicateExpression::parse(expressionIdentifier, parser, context, parameters); + expression = expressions::Predicate::parse(expressionIdentifier, parser, context, parameters); else throw utils::ParserException(parser.row(), parser.column(), "Expression \"" + expressionIdentifier + "\" not allowed in this context"); } @@ -194,8 +194,8 @@ ExpressionPointer parseEffectBodyExpressionContent(const std::string &expression //////////////////////////////////////////////////////////////////////////////////////////////////// -ExpressionPointer parsePredicateExpression(utils::Parser &parser, Context &context, - const expressions::VariableExpressions ¶meters) +ExpressionPointer parsePredicate(utils::Parser &parser, Context &context, + const expressions::Variables ¶meters) { parser.expect("("); @@ -214,7 +214,7 @@ ExpressionPointer parsePredicateExpression(utils::Parser &parser, Context &conte if (match == context.predicates.cend()) throw utils::ParserException(parser.row(), parser.column(), "Unknown predicate \"" + predicateName + "\""); - expression = expressions::PredicateExpression::parse(predicateName, parser, context, parameters); + expression = expressions::Predicate::parse(predicateName, parser, context, parameters); parser.expect(")"); diff --git a/src/plasp/pddl/expressions/OrExpression.cpp b/src/plasp/pddl/expressions/And.cpp similarity index 75% rename from src/plasp/pddl/expressions/OrExpression.cpp rename to src/plasp/pddl/expressions/And.cpp index 428e4aa..d7c19b0 100644 --- a/src/plasp/pddl/expressions/OrExpression.cpp +++ b/src/plasp/pddl/expressions/And.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -11,11 +11,11 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// OrExpression +// And // //////////////////////////////////////////////////////////////////////////////////////////////////// -void OrExpression::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const +void And::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const { expressionVisitor.visit(*this); } diff --git a/src/plasp/pddl/expressions/NAryExpression.cpp b/src/plasp/pddl/expressions/NAry.cpp similarity index 78% rename from src/plasp/pddl/expressions/NAryExpression.cpp rename to src/plasp/pddl/expressions/NAry.cpp index 10000d1..4fe4fd5 100644 --- a/src/plasp/pddl/expressions/NAryExpression.cpp +++ b/src/plasp/pddl/expressions/NAry.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -15,11 +15,11 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// NAryExpression +// NAry // //////////////////////////////////////////////////////////////////////////////////////////////////// -const std::vector> &NAryExpression::arguments() const +const Expressions &NAry::arguments() const { return m_arguments; } diff --git a/src/plasp/pddl/expressions/AndExpression.cpp b/src/plasp/pddl/expressions/Not.cpp similarity index 75% rename from src/plasp/pddl/expressions/AndExpression.cpp rename to src/plasp/pddl/expressions/Not.cpp index 0b274c9..e8eb925 100644 --- a/src/plasp/pddl/expressions/AndExpression.cpp +++ b/src/plasp/pddl/expressions/Not.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -11,11 +11,11 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// AndExpression +// Not // //////////////////////////////////////////////////////////////////////////////////////////////////// -void AndExpression::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const +void Not::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const { expressionVisitor.visit(*this); } diff --git a/src/plasp/pddl/expressions/NotExpression.cpp b/src/plasp/pddl/expressions/Or.cpp similarity index 75% rename from src/plasp/pddl/expressions/NotExpression.cpp rename to src/plasp/pddl/expressions/Or.cpp index 1f880b8..f6d135a 100644 --- a/src/plasp/pddl/expressions/NotExpression.cpp +++ b/src/plasp/pddl/expressions/Or.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -11,11 +11,11 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// NotExpression +// Or // //////////////////////////////////////////////////////////////////////////////////////////////////// -void NotExpression::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const +void Or::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const { expressionVisitor.visit(*this); } diff --git a/src/plasp/pddl/expressions/PredicateExpression.cpp b/src/plasp/pddl/expressions/Predicate.cpp similarity index 60% rename from src/plasp/pddl/expressions/PredicateExpression.cpp rename to src/plasp/pddl/expressions/Predicate.cpp index 8a17e38..a57608a 100644 --- a/src/plasp/pddl/expressions/PredicateExpression.cpp +++ b/src/plasp/pddl/expressions/Predicate.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -11,14 +11,14 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// PredicateExpression +// Predicate // //////////////////////////////////////////////////////////////////////////////////////////////////// -PredicateExpressionPointer PredicateExpression::parse(std::string name, utils::Parser &parser, - Context &context, const VariableExpressions ¶meters) +PredicatePointer Predicate::parse(std::string name, utils::Parser &parser, + Context &context, const Variables ¶meters) { - auto expression = std::make_unique(PredicateExpression()); + auto expression = std::make_unique(Predicate()); expression->m_name = name; @@ -26,7 +26,7 @@ PredicateExpressionPointer PredicateExpression::parse(std::string name, utils::P // Parse arguments while (parser.currentCharacter() != ')') - expression->m_arguments.emplace_back(VariableExpression::parse(parser, parameters)); + expression->m_arguments.emplace_back(Variable::parse(parser, parameters)); // TODO: check that signature matches one of the declared ones @@ -35,14 +35,14 @@ PredicateExpressionPointer PredicateExpression::parse(std::string name, utils::P //////////////////////////////////////////////////////////////////////////////////////////////////// -void PredicateExpression::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const +void Predicate::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const { expressionVisitor.visit(*this); } //////////////////////////////////////////////////////////////////////////////////////////////////// -const std::vector &PredicateExpression::arguments() const +const std::vector &Predicate::arguments() const { return m_arguments; } diff --git a/src/plasp/pddl/expressions/VariableExpression.cpp b/src/plasp/pddl/expressions/Variable.cpp similarity index 67% rename from src/plasp/pddl/expressions/VariableExpression.cpp rename to src/plasp/pddl/expressions/Variable.cpp index c578113..1a725d4 100644 --- a/src/plasp/pddl/expressions/VariableExpression.cpp +++ b/src/plasp/pddl/expressions/Variable.cpp @@ -1,4 +1,4 @@ -#include +#include #include @@ -16,24 +16,24 @@ namespace expressions //////////////////////////////////////////////////////////////////////////////////////////////////// // -// VariableExpression +// Variable // //////////////////////////////////////////////////////////////////////////////////////////////////// -VariableExpression::VariableExpression() +Variable::Variable() : m_isDirty{false} { } //////////////////////////////////////////////////////////////////////////////////////////////////// -VariableExpressionPointer VariableExpression::parseDeclaration(utils::Parser &parser) +VariablePointer Variable::parseDeclaration(utils::Parser &parser) { parser.skipWhiteSpace(); parser.expect("?"); - auto variable = std::make_unique(VariableExpression()); + auto variable = std::make_unique(Variable()); variable->m_name = parser.parseIdentifier(isIdentifier); variable->setDirty(); @@ -43,11 +43,10 @@ VariableExpressionPointer VariableExpression::parseDeclaration(utils::Parser &pa //////////////////////////////////////////////////////////////////////////////////////////////////// -void VariableExpression::parseTypedDeclaration(utils::Parser &parser, Context &context, - VariableExpressions &variableExpressions) +void Variable::parseTypedDeclaration(utils::Parser &parser, Context &context, Variables &variables) { // Parse and store variable itself - variableExpressions.emplace_back(parseDeclaration(parser)); + variables.emplace_back(parseDeclaration(parser)); parser.skipWhiteSpace(); @@ -59,7 +58,7 @@ void VariableExpression::parseTypedDeclaration(utils::Parser &parser, Context &c const auto type = parseType(parser, context); // Set the argument type for all previously flagged arguments - std::for_each(variableExpressions.begin(), variableExpressions.end(), + std::for_each(variables.begin(), variables.end(), [&](auto &variable) { if (!variable->isDirty()) @@ -72,8 +71,7 @@ void VariableExpression::parseTypedDeclaration(utils::Parser &parser, Context &c //////////////////////////////////////////////////////////////////////////////////////////////////// -const VariableExpression *VariableExpression::parse(utils::Parser &parser, - const VariableExpressions &variableExpressions) +const Variable *Variable::parse(utils::Parser &parser, const Variables &variables) { parser.skipWhiteSpace(); @@ -81,13 +79,13 @@ const VariableExpression *VariableExpression::parse(utils::Parser &parser, const auto variableName = parser.parseIdentifier(isIdentifier); - const auto match = std::find_if(variableExpressions.cbegin(), variableExpressions.cend(), - [&](const auto &variableExpression) + const auto match = std::find_if(variables.cbegin(), variables.cend(), + [&](const auto &variable) { - return variableExpression->name() == variableName; + return variable->name() == variableName; }); - if (match == variableExpressions.cend()) + if (match == variables.cend()) throw utils::ParserException(parser.row(), parser.column(), "Variable \"" + variableName + "\" used but never declared"); return match->get(); @@ -95,42 +93,42 @@ const VariableExpression *VariableExpression::parse(utils::Parser &parser, //////////////////////////////////////////////////////////////////////////////////////////////////// -void VariableExpression::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const +void Variable::accept(plasp::pddl::ExpressionVisitor &expressionVisitor) const { expressionVisitor.visit(*this); } //////////////////////////////////////////////////////////////////////////////////////////////////// -const std::string &VariableExpression::name() const +const std::string &Variable::name() const { return m_name; } //////////////////////////////////////////////////////////////////////////////////////////////////// -TypePtr VariableExpression::type() const +TypePtr Variable::type() const { return m_type; } //////////////////////////////////////////////////////////////////////////////////////////////////// -void VariableExpression::setDirty(bool isDirty) +void Variable::setDirty(bool isDirty) { m_isDirty = isDirty; } //////////////////////////////////////////////////////////////////////////////////////////////////// -bool VariableExpression::isDirty() const +bool Variable::isDirty() const { return m_isDirty; } //////////////////////////////////////////////////////////////////////////////////////////////////// -void VariableExpression::setType(TypePtr type) +void Variable::setType(TypePtr type) { m_type = type; }