2016-06-02 16:06:11 +02:00
|
|
|
#ifndef __PLASP__PDDL__EXPRESSION_H
|
|
|
|
#define __PLASP__PDDL__EXPRESSION_H
|
|
|
|
|
2016-06-02 16:28:08 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2016-06-02 16:06:11 +02:00
|
|
|
#include <plasp/utils/Parser.h>
|
|
|
|
|
|
|
|
namespace plasp
|
|
|
|
{
|
|
|
|
namespace pddl
|
|
|
|
{
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Expression
|
|
|
|
//
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
class Context;
|
2016-06-07 13:26:19 +02:00
|
|
|
class Domain;
|
|
|
|
class ExpressionContext;
|
2016-06-02 16:28:08 +02:00
|
|
|
class ExpressionVisitor;
|
2016-06-07 13:26:19 +02:00
|
|
|
class Problem;
|
2016-06-02 16:28:08 +02:00
|
|
|
|
2016-06-03 13:20:52 +02:00
|
|
|
class Expression;
|
|
|
|
using ExpressionPointer = std::unique_ptr<Expression>;
|
|
|
|
using Expressions = std::vector<ExpressionPointer>;
|
|
|
|
|
|
|
|
namespace expressions
|
|
|
|
{
|
2016-06-03 13:33:05 +02:00
|
|
|
class And;
|
|
|
|
using AndPointer = std::unique_ptr<And>;
|
2016-06-03 13:20:52 +02:00
|
|
|
|
2016-06-13 19:02:15 +02:00
|
|
|
class At;
|
|
|
|
using AtPointer = std::unique_ptr<At>;
|
|
|
|
|
2016-06-03 17:12:39 +02:00
|
|
|
class Constant;
|
|
|
|
using ConstantPointer = std::unique_ptr<Constant>;
|
|
|
|
using Constants = std::vector<ConstantPointer>;
|
|
|
|
|
|
|
|
class Either;
|
|
|
|
using EitherPointer = std::unique_ptr<Either>;
|
|
|
|
|
2016-06-04 17:20:25 +02:00
|
|
|
class Imply;
|
|
|
|
using ImplyPointer = std::unique_ptr<Imply>;
|
|
|
|
|
2016-06-03 13:33:05 +02:00
|
|
|
class Not;
|
|
|
|
using NotPointer = std::unique_ptr<Not>;
|
2016-06-03 13:20:52 +02:00
|
|
|
|
2016-06-03 13:33:05 +02:00
|
|
|
class Or;
|
|
|
|
using OrPointer = std::unique_ptr<Or>;
|
2016-06-03 13:20:52 +02:00
|
|
|
|
2016-06-03 13:33:05 +02:00
|
|
|
class Predicate;
|
|
|
|
using PredicatePointer = std::unique_ptr<Predicate>;
|
2016-06-03 17:12:39 +02:00
|
|
|
using Predicates = std::vector<PredicatePointer>;
|
|
|
|
|
|
|
|
class PredicateDeclaration;
|
|
|
|
using PredicateDeclarationPointer = std::unique_ptr<PredicateDeclaration>;
|
|
|
|
using PredicateDeclarations = std::vector<PredicateDeclarationPointer>;
|
|
|
|
|
|
|
|
class PrimitiveType;
|
|
|
|
using PrimitiveTypePointer = std::unique_ptr<PrimitiveType>;
|
|
|
|
using PrimitiveTypes = std::vector<PrimitiveTypePointer>;
|
|
|
|
|
2016-06-14 01:31:22 +02:00
|
|
|
class Unsupported;
|
|
|
|
using UnsupportedPointer = std::unique_ptr<Unsupported>;
|
|
|
|
|
2016-06-03 13:33:05 +02:00
|
|
|
class Variable;
|
|
|
|
using VariablePointer = std::unique_ptr<Variable>;
|
|
|
|
using Variables = std::vector<VariablePointer>;
|
2016-06-03 13:20:52 +02:00
|
|
|
}
|
|
|
|
|
2016-06-02 16:28:08 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
2016-06-02 16:06:11 +02:00
|
|
|
|
2016-06-02 16:28:08 +02:00
|
|
|
class Expression
|
2016-06-02 16:06:11 +02:00
|
|
|
{
|
2016-06-02 16:28:08 +02:00
|
|
|
public:
|
2016-06-12 22:12:09 +02:00
|
|
|
enum class Type
|
|
|
|
{
|
|
|
|
And,
|
2016-06-13 19:02:15 +02:00
|
|
|
At,
|
2016-06-12 22:12:09 +02:00
|
|
|
Binary,
|
|
|
|
Constant,
|
|
|
|
Either,
|
|
|
|
Imply,
|
|
|
|
Not,
|
|
|
|
Or,
|
|
|
|
PredicateDeclaration,
|
|
|
|
Predicate,
|
|
|
|
PrimitiveType,
|
2016-06-14 01:31:22 +02:00
|
|
|
Unsupported,
|
2016-06-12 22:12:09 +02:00
|
|
|
Variable
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~Expression() = default;
|
|
|
|
|
|
|
|
virtual Type expressionType() const = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
template<class Derived>
|
|
|
|
class ExpressionCRTP: public Expression
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Type expressionType() const override final
|
|
|
|
{
|
|
|
|
return Derived::ExpressionType;
|
|
|
|
}
|
2016-06-02 16:28:08 +02:00
|
|
|
};
|
2016-06-02 16:06:11 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-06-13 19:02:15 +02:00
|
|
|
ExpressionPointer parseLiteral(Context &context, ExpressionContext &expressionContext);
|
|
|
|
ExpressionPointer parseAtomicFormula(Context &context, ExpressionContext &expressionContext);
|
|
|
|
|
2016-06-04 16:24:10 +02:00
|
|
|
ExpressionPointer parsePreconditionExpression(Context &context,
|
2016-06-07 13:26:19 +02:00
|
|
|
ExpressionContext &expressionContext);
|
|
|
|
ExpressionPointer parseExpression(Context &context, ExpressionContext &expressionContext);
|
2016-06-02 16:06:11 +02:00
|
|
|
|
2016-06-07 13:26:19 +02:00
|
|
|
ExpressionPointer parseEffectExpression(Context &context,
|
|
|
|
ExpressionContext &expressionContext);
|
2016-06-02 21:53:10 +02:00
|
|
|
|
2016-06-02 16:06:11 +02:00
|
|
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|