Shortened Expression class names.
This commit is contained in:
parent
d334b4150b
commit
133aa051eb
@ -4,7 +4,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include <plasp/pddl/Expression.h>
|
||||
#include <plasp/pddl/expressions/VariableExpression.h>
|
||||
#include <plasp/pddl/expressions/Variable.h>
|
||||
#include <plasp/utils/Parser.h>
|
||||
|
||||
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<Expression> m_precondition;
|
||||
std::unique_ptr<Expression> m_effect;
|
||||
};
|
||||
|
@ -28,21 +28,21 @@ using Expressions = std::vector<ExpressionPointer>;
|
||||
|
||||
namespace expressions
|
||||
{
|
||||
class AndExpression;
|
||||
using AndExpressionPointer = std::unique_ptr<AndExpression>;
|
||||
class And;
|
||||
using AndPointer = std::unique_ptr<And>;
|
||||
|
||||
class NotExpression;
|
||||
using NotExpressionPointer = std::unique_ptr<NotExpression>;
|
||||
class Not;
|
||||
using NotPointer = std::unique_ptr<Not>;
|
||||
|
||||
class OrExpression;
|
||||
using OrExpressionPointer = std::unique_ptr<OrExpression>;
|
||||
class Or;
|
||||
using OrPointer = std::unique_ptr<Or>;
|
||||
|
||||
class PredicateExpression;
|
||||
using PredicateExpressionPointer = std::unique_ptr<PredicateExpression>;
|
||||
class Predicate;
|
||||
using PredicatePointer = std::unique_ptr<Predicate>;
|
||||
|
||||
class VariableExpression;
|
||||
using VariableExpressionPointer = std::unique_ptr<VariableExpression>;
|
||||
using VariableExpressions = std::vector<VariableExpressionPointer>;
|
||||
class Variable;
|
||||
using VariablePointer = std::unique_ptr<Variable>;
|
||||
using Variables = std::vector<VariablePointer>;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -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);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -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 <plasp/pddl/expressions/NAryExpression.h>
|
||||
#include <plasp/pddl/expressions/NAry.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
@ -12,33 +12,33 @@ namespace expressions
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// AndExpression
|
||||
// And
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class AndExpression: public NAryExpression
|
||||
class And: public NAry
|
||||
{
|
||||
public:
|
||||
template<typename ExpressionParser>
|
||||
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<typename ExpressionParser>
|
||||
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>(AndExpression());
|
||||
auto expression = std::make_unique<And>(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");
|
@ -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 <memory>
|
||||
#include <string>
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
#include <plasp/pddl/ConsistencyException.h>
|
||||
#include <plasp/pddl/Expression.h>
|
||||
#include <plasp/pddl/expressions/VariableExpression.h>
|
||||
#include <plasp/pddl/expressions/Variable.h>
|
||||
#include <plasp/utils/Parser.h>
|
||||
|
||||
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<typename ExpressionParser>
|
||||
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<typename ExpressionParser>
|
||||
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();
|
||||
|
@ -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 <plasp/pddl/Expression.h>
|
||||
#include <plasp/pddl/Predicate.h>
|
||||
@ -13,16 +13,16 @@ namespace expressions
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NotExpression
|
||||
// Not
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class NotExpression: public Expression
|
||||
class Not: public Expression
|
||||
{
|
||||
public:
|
||||
template<typename ExpressionParser>
|
||||
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<typename ExpressionParser>
|
||||
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>(NotExpression());
|
||||
auto expression = std::make_unique<Not>(Not());
|
||||
|
||||
parser.skipWhiteSpace();
|
||||
|
@ -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 <plasp/pddl/expressions/NAryExpression.h>
|
||||
#include <plasp/pddl/expressions/NAry.h>
|
||||
|
||||
namespace plasp
|
||||
{
|
||||
@ -12,33 +12,33 @@ namespace expressions
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// OrExpression
|
||||
// Or
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class OrExpression: public NAryExpression
|
||||
class Or: public NAry
|
||||
{
|
||||
public:
|
||||
template<typename ExpressionParser>
|
||||
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<typename ExpressionParser>
|
||||
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>(OrExpression());
|
||||
auto expression = std::make_unique<Or>(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");
|
@ -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 <plasp/pddl/Expression.h>
|
||||
#include <plasp/pddl/Predicate.h>
|
||||
#include <plasp/pddl/expressions/VariableExpression.h>
|
||||
#include <plasp/pddl/expressions/Variable.h>
|
||||
|
||||
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<const VariableExpression *> &arguments() const;
|
||||
const std::vector<const Variable *> &arguments() const;
|
||||
|
||||
private:
|
||||
PredicateExpression() = default;
|
||||
Predicate() = default;
|
||||
|
||||
std::string m_name;
|
||||
std::vector<const VariableExpression *> m_arguments;
|
||||
std::vector<const Variable *> m_arguments;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
@ -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 <plasp/pddl/Expression.h>
|
||||
|
||||
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
#include <plasp/pddl/Context.h>
|
||||
#include <plasp/pddl/Identifier.h>
|
||||
#include <plasp/pddl/expressions/AndExpression.h>
|
||||
#include <plasp/pddl/expressions/NotExpression.h>
|
||||
#include <plasp/pddl/expressions/OrExpression.h>
|
||||
#include <plasp/pddl/expressions/PredicateExpression.h>
|
||||
#include <plasp/pddl/expressions/And.h>
|
||||
#include <plasp/pddl/expressions/Not.h>
|
||||
#include <plasp/pddl/expressions/Or.h>
|
||||
#include <plasp/pddl/expressions/Predicate.h>
|
||||
#include <plasp/utils/ParserException.h>
|
||||
|
||||
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<std::string>("(");
|
||||
|
||||
@ -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<std::string>("(");
|
||||
|
||||
@ -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<std::string>("(");
|
||||
|
||||
@ -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<std::string>("(");
|
||||
|
||||
@ -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<std::string>(")");
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <plasp/pddl/expressions/OrExpression.h>
|
||||
#include <plasp/pddl/expressions/And.h>
|
||||
|
||||
#include <plasp/pddl/ExpressionVisitor.h>
|
||||
|
||||
@ -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);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include <plasp/pddl/expressions/NAryExpression.h>
|
||||
#include <plasp/pddl/expressions/NAry.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -15,11 +15,11 @@ namespace expressions
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// NAryExpression
|
||||
// NAry
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
const std::vector<std::unique_ptr<Expression>> &NAryExpression::arguments() const
|
||||
const Expressions &NAry::arguments() const
|
||||
{
|
||||
return m_arguments;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include <plasp/pddl/expressions/AndExpression.h>
|
||||
#include <plasp/pddl/expressions/Not.h>
|
||||
|
||||
#include <plasp/pddl/ExpressionVisitor.h>
|
||||
|
||||
@ -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);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include <plasp/pddl/expressions/NotExpression.h>
|
||||
#include <plasp/pddl/expressions/Or.h>
|
||||
|
||||
#include <plasp/pddl/ExpressionVisitor.h>
|
||||
|
||||
@ -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);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include <plasp/pddl/expressions/PredicateExpression.h>
|
||||
#include <plasp/pddl/expressions/Predicate.h>
|
||||
|
||||
#include <plasp/pddl/ExpressionVisitor.h>
|
||||
|
||||
@ -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>(PredicateExpression());
|
||||
auto expression = std::make_unique<Predicate>(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<const VariableExpression *> &PredicateExpression::arguments() const
|
||||
const std::vector<const Variable *> &Predicate::arguments() const
|
||||
{
|
||||
return m_arguments;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include <plasp/pddl/expressions/VariableExpression.h>
|
||||
#include <plasp/pddl/expressions/Variable.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -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<std::string>("?");
|
||||
|
||||
auto variable = std::make_unique<VariableExpression>(VariableExpression());
|
||||
auto variable = std::make_unique<Variable>(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;
|
||||
}
|
Reference in New Issue
Block a user